yayuj

Experience

14,325

5 Best Reply Awards

  • Member Since 3 Years Ago
  • 0 Lessons Completed
  • 0 Favorites

6th March, 2015

yayuj left a reply on Questions You Frequently Ask Yourself While Coding • 3 years ago

@Ruffles - +1 - I often do that using exceptions. :P

@Chris Magnussen - Early return, mostly.

yayuj left a reply on Questions You Frequently Ask Yourself While Coding • 3 years ago

@Chris Magnussen - Have you ever heard about object calisthenics? - Recommend you guys to read about it.

yayuj left a reply on Questions You Frequently Ask Yourself While Coding • 3 years ago

@toniperic - You are welcome. - You can find really good programmers around here, and I'm sure that you will grow as much as I did here with them.

yayuj left a reply on Questions You Frequently Ask Yourself While Coding • 3 years ago

It happens with any programmer, the thing is for you to don't hang yourself because you think something will change in the future - and it will. Everything changes, requirements change, as well as all Pokemon evolves... I want to tell you something that unfortunately is still something unknown to many developers., OO = OOA, OOD, OOP. If you have no idea what I just said you are one of them, but this is about to change and this will help you. It is really common for us programmers to start thinking in code and jump two fundamentals steps that is analysis (OOA) and design (OOD), and that is where the solution lies. We are programmers and our goal is to understand problems and solve them (most often), but you cannot understand the problem if you don't make some analysis first and then design what you are going to do in order to solve that problem. - Have you ever stopped in front of the editor and asked yourself: What am I going to do now? - It happens, believe me. - Or have you the problem to start a project and never release waiting for perfection? If you make analysis first you will notice what can change and what won't, at least not in a close future, but one principle that you have to follow is Program to an interface, not an implementation, because using interfaces is a key factor in making your code easily testable in addition to removing unnecessary couplings between your classes. By creating an interface that defines the operations on your class, you allow classes that want to use that functionality the ability to use it without depending on your implementing class directly. If later on you decide to change and use a different implementation, you need only change the part of the code where the implementation is instantiated. The rest of the code need not change because it depends on the interface, not the implementing class. - For example: When I say chair what you imagine? - I'm not imagining the same chair as you are, I'm imagining a chair with flowers in a red color (fancy right?), but well, what is wrong with that? It can change, I might want to change that chair in the future for one iron chair with cushions. A solution is to use an interface, you can create an idea of chair. - And don't worry about too much interfaces in your project, they are not a problem, actually the sign of interfaces in your code shows that your project is flexible. Interfaces are types, as well they are contracts. with that you CAN trust on implementations because they are following some rules, and with that you can be even more flexible using IOC, for instance, as well make your code more testable. Just to make a resume: You have to analyze what you are doing, what you have to do and don't overdo. Keep it simple, but flexible. Stick with abstraction, think abstract and you will see your code without dependencies. - If you see that you are with too much dependencies between classes like dependency injection and you code will only work if you inject dependencies here there and there and there, and here and there again, don't worry, it's a good sign, you can solve that using an IOC Container.

There are much more, SOLID, IOC, DI, abstraction, interfaces, and some principle (like DRY, YAGNI, KISS). - Be nice and start projecting before developing... an idea is just an idea without a project. ;) ♥

yayuj left a reply on E-commerce • 3 years ago

@frezno - Thank you, it will help a lot - @deringer - I don't know, I always take a step back with services like that, I prefer to see the code and change, have the control of the situation. @freekmurze - Just beautiful beautiful, I've seen Polkadots, can you believe that? I found amazing - I will be following your blog, I hope it helps me. Thank you for that.

5th March, 2015

yayuj left a reply on E-commerce • 3 years ago

@sitesense - Thank you - I decided that I will stick with Laravel, I talked briefly with the client and what she wants is something simple. She is selling clothes and things that she does. - I'm gathering information in order to make the business model, as it is simple I will try to make it as scalable as possible and if she wants to change something on the future it won't be a pain... we never know but I will avoid overdoing as you mentioned above. - My (and of others around the globe) beef with OpenCart cross the boundaries of unboundedness, don't worth mentioning.

yayuj left a reply on E-commerce • 3 years ago

I just found Sylius built on top of Symfony2 - just like Laravel - I will give it a try.

yayuj started a new conversation E-commerce • 3 years ago

Hey'all I need to create an e-commerce to a client but I'm running out of options related to platform... OpenCart sucks (sorry for those who likes it, you suck as well - ♥), Magento is PITA, hard to understand and slow and I don't think that it fits well to a small e-commerce. Is it advantageous to create a custom e-commerce on top of Laravel? Or there's a platform on the market (open source) that is similar to Laravel (in concepts etc)? Thanks in advance.

4th March, 2015

yayuj started a new conversation Laravel "models" Folder • 3 years ago

Why there's no models folder in Laravel anymore? Was it a way to don't conduct people to think that "models == database"? - Was it a way to say "create your own domain folder and start putting your stuffs there - entities, value objects, repos, commands etc"?

yayuj left a reply on Eloquent Bug • 3 years ago

"cakephp" - I see. haha (kidding).

yayuj left a reply on Eloquent Bug • 3 years ago

@fico7489 - It's irrelevant now, you solved your problems, we are all here to help each other, not as butlers to serve. - What he wanted to say is that you should prepare better your questions if you want us to help you out.

yayuj left a reply on Eloquent Bug • 3 years ago

@fico7489 - I don't think so, if you store a number (I mean, an integer) in a character type field you require the mysql engine to implicitly cast the value. - For example, the differences between char, varchar, text, longtext, mediumtext, tinytext are merely the size. - You can use cast(field as unsigned)). - I don't recommend that, of course, unless you must to do that.

yayuj left a reply on Eloquent Bug • 3 years ago

@fico7489 - I think that you should make a question instead of pointing something that does not make sense for us. What are you trying to do? Retrieve the total of cars from the database with the kilometers above 8000,, 10000, 15000, or what? Show us your database structure, how the data is inserted and so on.

yayuj left a reply on Eloquent Bug • 3 years ago

You do know that count(*) means that you are counting every single field, not only the kilometers right? If that is what you are trying to count... of course.

yayuj left a reply on MVC Questions • 3 years ago

In general, I think MVC misses the point of modern web applications - there's more to it than that now.

Agreed. AFAIK one person who matured these terms was Fabien Potencier implementing Symfony and presenting to the world new technologies and patterns. If you look at the source code of old frameworks you will see that most of them doesn't implement most of the things we have now. An example is ZF1, they implemented the service locator (anti-)pattern, and now they have their IOC container, why? Because things evolve.

What's more is, as back ends shift more towards exposing simple APIs that rich front-ends like Angular consume, the idea of views/templates becomes less and less relevant, and the idea of Routes -> Requests -> Domain -> Response starts to fit that paradigm a little better.

Also agreed. JavaScript has grown, today we can do wonderful things with it. An example is L5 that removed the HTML package for that reason and Elixir is here to prove it as well.

I personally like the notation of Paul M Jones's Action Domain Responder, as I think that's a bit more to the point than Model View Controller is. However, it's still just a trifecta, when in reality, modern web applications have a broader architecture than just 3 layers.

It is good to now that notation. Do you think that we are beyond MVC already? I mean, using MVC as reference but doing much more that it presented for us in the beginning? - As you quoted, we have much more nowadays, isn't it a new thing?

6 - Domain Layer - aka "Model" (events, repositories, entities, value objects, classes, classes, classes... anything that is your business/domain logic)

I got confused here... It's really easy to see frameworks with a "models" folder and people describes the model as the part where we make things related to the database... Am I wrong or it changed? - A example is L5, now we don't have the models folder, we just have controllers and views, you will often find model classes outside of a folder (inside the app folder, I mean), or maybe in a folder like "Acme - tutorials/playground related" or "Domain" (in this case that folder would be the domain layer, where we should locate the events, repositories, entities, value objects, classes, classes, classes... blabla, right?) - Is that the same folder where I should put the models classes as well? - You said in a post about DDD that the connections with the database is related with infrastructure and it can be a separated layer, what is the relation (if there's one)? - I feel more lost than a blind in a gunfire.

3rd March, 2015

yayuj left a reply on MVC Questions • 3 years ago

I have to build an e-commerce to a client, I'm talking with him, understanding his problem (domain) in order to start making the domain model, and I'm thinking in follow the KISS principle and start with MVC. The thing is that I'm kinda crazy with that, I start simply but then, from the sudden, I'm making the world. - Any advices in what I would be doing? I should be starting with MVC or other architecture would help more?

yayuj left a reply on MVC Questions • 3 years ago

@radbonev - Genial that example of human intelligence.

I also agree that there is nothing wrong with MVC, what is wrong is the way in which people use.

I've met people who have been through situations in which they claimed that they had a problem and this problem was with the language or tool, because it was not possible that what they were doing was wrong, was totally illogical, but in reality, they forgot that the problem, most often (or always), is not the language or tool, but ourselves, programmers. Of course, it is entirely possible to be a problem in the language or tool, but again, most often the problem is ourselves.

There are those who love TDD for example, there are others who say that TDD does not work, but why it does not work? I guarantee it works, but how can I give this information like that? Simply because I do not jump two important steps related to object orientation which is the analysis and design, I will not refer to DDD because DDD itself is a process that is related with design, so if the programmer is learning or is already a pro they might know what they are doing or maybe they have been through the same problems. - There are programmers who think that OO is OOP. (believe me).

The point is that we do misuse of many things, design patterns, architecture patterns, they are usually described in an abstract way where you will use that description/idea to try to solve a repetitive problem, a problem that has happened before, maybe similar, but that does not leave the main essence of the problem, but even so, we do take a supposed solution and make it an even bigger problem.

You quoted that we have problems understanding poorly structured things and this made me think of something else: The reason there are so many patterns do not help that much and that is a kind of burden for us programmers, because MVC will not always solve all the problems, then we have to go and search a new architecture pattern to solve that problem in specific, and this is very exhausting.

Today, searching on architectural patterns I found another known as Flux, in which Facebook developers claim that the MVC does not scale and Flux is the best option. Now I just met another in your posting, MOVE, also has the hexagonal (ports and adapters), and several others.

What happens is that, returning to the question of MVC, it is impossible to implement something on top of the MVC without having knowledge of other patterns, principles and know the correct way (or best) to do something.

@alenabdula, @Ruffles, @jekinney - opinions?

yayuj started a new conversation MVC Questions • 3 years ago

Hi family, as I know that we have a lot of smart people around here and with different visions about certain subjects, this time I want to create a topic about MVC.

  • What you think about MVC?
  • Does MVC combines with the web?
  • Why there's still frameworks that uses MVC?
  • What is wrong with MVC?
  • What is the wrong and the right way to implement MVC?
  • What is the responsibility of the models, views and controllers?

And of course, links, places with good stuffs, advanced ones as well.

MVC is an advanced architectural design pattern, which requires solid understanding. It is not meant for beginners or for tiny "hello world" applications. - tereško

2nd March, 2015

yayuj left a reply on DDD Questions • 3 years ago

@Ruffles - Thank you very much @Ruffles.

yayuj left a reply on DDD Questions • 3 years ago

Seriously guys, that is why I love being here. If I was a girl I'd kiss you all. (haha) - Thanks.

1st March, 2015

yayuj left a reply on DDD Questions • 3 years ago

@Ruffles - Thank you, I will leave it opened, maybe other folks can have more to add.

yayuj started a new conversation DDD Questions • 3 years ago

I'm trying to study DDD but I'm really confused with some terminologies they use to describe several things, they made my little brain fry like an egg.

  • What is domain logic, domain layer, business logic, business layer, domain model, domain object, domain event, domain expert, core domain?
  • How to detect them within my code?
  • Is Laravel made above those DDD concepts? (I often see things like service, repository, etc).
  • Where I can find a place to learn DDD in an easy way? (I mean, really easy way).

27th February, 2015

yayuj started a new conversation Question About IoC Container (Service Container) • 3 years ago

What is the association of IoC Container (Service Container) with factories, objects and classes? I often see in IoC Containers that description, that they can "resolve" factories, objects and classes. What this mean?

25th February, 2015

yayuj started a new conversation What Is The Name Of That Kind Of API? • 3 years ago

Is there a name to define that kind of API?

$this->do(function() { // ... })->when('...')->call('...');

This is just an example, of course.

21st February, 2015

yayuj left a reply on The History • 3 years ago

I want to get inspired, that is the reason I want to know the history behind Laravel. - Thank you all folks, that is why I love being here.

yayuj left a reply on The History • 3 years ago

@bashy - I couldn't find, I searched on Youtube but nothing. - Thanks @Ricardo.

20th February, 2015

yayuj left a reply on The History • 3 years ago

I'm a poor guy, I don't use Twitter. I'd have 1 follower, my mom.

yayuj left a reply on The History • 3 years ago

@blackbird - Thanks, I didn't knew about that post. I'm going to read.

It would be nice to hear from @JeffeyWay and @TaylorOtwell about their history along with Laravel.

I have one question: Why Laravel uses Symfony behind the scenes? I heard a few days ago some Zend developers saying that Laravel sucks, it's just a bouch of adapters. (Of course I don't share the same thought - but I would like to hear why).

yayuj started a new conversation The History • 3 years ago

Guys is there any video or audio of Taylor or anyone else talking about the beginning of Laravel? How it started? How he convinced people to use it? Was it a hard beginning? And things related? Thanks.

yayuj left a reply on I Want To Create An Application, But... • 3 years ago

@andy - Thanks - @ShutteR - You're right... but I love programming, then in this case, I have to do something with what I love. haha.

yayuj started a new conversation Laravel Communty Numbers... • 3 years ago

Is there any numbers of how many people is evolved on Laravel? I mean, contributors, companies that supports, downloads, people in general aspects like in forums and so on?

19th February, 2015

yayuj left a reply on I Want To Create An Application, But... • 3 years ago

@andy - I made this thread because as I said, the area of the application is not mine, I'm a programmer, you know?

Do you guys have any ideas of how I can make this? Online? Face to face? Do I need to make a prototype or anything similar?

yayuj left a reply on I Want To Create An Application, But... • 3 years ago

You're right, now I need to choose which companies to try this approach, which questions to ask, who to talk to, and everything. - This might help.

There are some applications similar on the market, but most of them is expensive, hard to use, and so on (and in other languages).

yayuj started a new conversation I Want To Create An Application, But... • 3 years ago

I want to create an application, but the area of the application is not mine, I mean, I know pretty much nothing about, but I know that the market has a lack of that here. The application is about companies, and I feel insecure of building the application and do it wrong, try to sell and don't know how to sell.

I would like some advices, what can I do? Stop the idea and do things related to my area? or anything else?

Thank you all.

10th February, 2015

yayuj started a new conversation Tutorials Category • 3 years ago

I would love to share some experiences that I have here, and also the experiences that I'm having learning new things everyday, after all, one of the best ways to learn is teaching, right?

Why not a new channel here? A tutorials channel.

yayuj left a reply on You Can Now Autocomplete Usernames • 3 years ago

It would be nice to appear some kind of 'loading', because when the person types @ means that he is trying to mark someone, then instead of be waiting the entire process in the dark, why don't show a kind of 'I'm working'? I tried to use now and I needed to wait a few seconds to realized that it was working.

yayuj left a reply on Follow Thread • 3 years ago

9th February, 2015

yayuj left a reply on Expecting The Return • 3 years ago

I solved:

$result = $this->foo->order();
$this->assertEquals('you made it', $result);

yayuj started a new conversation Expecting The Return • 3 years ago

I'm testing an object Foo that accepts other object Bar via constructor, I'm testing Bar separated, and now I'm going to test Foo, the thing is: How I make sure that a method of Foo is calling a method of Bar and returning the expected result?

Example: // setUp $this->bar = $this->getMock(Bar::class); $this->foo = new Foo($this->bar);

// test
$this->bar->expects($this->once())->method('make');
$this->foo->order();

Yes, this works, because order calls make, but how can I know if make is returning what I want? Let's suppose that I want make to return a string with you made it.

I tried that way:

$this->bar->expects($this->once())->method('make')->willReturn('you made it');

But now how can I test the return of the mock against the concrete class (the real return)?

yayuj started a new conversation @uses Question • 3 years ago

I was watching a video on Youtube and the creator of the PHPUnit said that it was a best practice to comment the tests using the @covers and @uses because it avoids the coverage to cover a place where it shouldn't be covered and also because the tests are also a kind of documentation. The question that I have is: I'm testing a method and that method calls other method that instantiate other class. foo method calls bar method and bar method instantiate Biz class, and Biz class implements Fiz that is an interface... when testing the foo method, am I using Biz class (the concrete one), or using the Fiz the interface that Biz implements?

yayuj started a new conversation Change The Channel When Editing A Conversation • 3 years ago

I realized that I made a new conversation on the wrong channel and I wanted to change, but I couldn't find how, I tried to edit, but there's no option to change the channel there.

yayuj left a reply on Testing Abstract And Concrete Classes • 3 years ago

@pmall, @JeffreyWay - Thanks ♥

yayuj started a new conversation Testing Abstract And Concrete Classes • 3 years ago

I'm entering in the world of the unit testing and I have some questions.

  • What about testing abstract classes? Is there any rule about that? When to test and when to don't?
  • Do I have to test all the concrete classes that I have in my project? Is there any exception?
  • For example, I have an interface CarFactory and I have Chevrolet and Ford that implements this interface. I have to test the concrete classes right? - what i have have more 20 factories?

Thanks. :)

yayuj left a reply on Factory Pattern Implementation • 3 years ago

@shahinul87 - Amazing, thank you.

8th February, 2015

yayuj started a new conversation Factory Pattern Implementation • 3 years ago

Hi guys, do you know where I can find implementations of the static, simple, method and abstract factory with tests? Anywhere. - It can be in the source of some framework, library, or anywhere else, I just want to understand how they implement in real world and test them.

Thanks in advance.

yayuj started a new conversation Code Review: Factories (Simple, Method, Abstract) • 3 years ago

Hi guys, I'm studying design patterns and I made some implementations of the factories, although I'm confident that the idea is right, I'm not confident that the implementation is good, specially the tests. - I would like you guys to check it out and give me some advices.

https://gist.github.com/anonymous/f4b3e19af158f0cde10f - Simple Factory https://gist.github.com/anonymous/1747807767260682e4a9 - Simple Factory Test

https://gist.github.com/anonymous/ca1a7a6552c6125b7032 - Factory Method https://gist.github.com/anonymous/d6c88f05558f08585bff - Factory Method Test

https://gist.github.com/anonymous/f0c4442175c23b9fe101 - Abstract Factory

The Abstract Factory doesn't have tests, I couldn't do it. I tried. - I want help specially with this one, because I'm using an abstract class with a private method, and that is what is making my head to blow when trying to test.

yayuj left a reply on Testing A Method That Calls Other Method • 3 years ago

"It doesn't matter if the method calls another method; you're still writing tests against the output. So it makes no difference."

@JeffreyWay - What you mean with that?

This is just an example of code that I'm write. This is actually an abstract factory pattern where the abstract factory has a private method and two other public. The factories that inherits from the abstract factory will only pass the arrays that the factory can create using the constructor. Example:

abstract class WidgetFactory {

 private $button = [];
private $panels = [];

function __construct(array $button, array $panels)
{
    $this->button = $button;
    $this->panels = $panels;
}

public function makeButton($name)
    {
  return $this->makeWidget($this->button, $name);
  }

 public function makePanels($name)
  {
   return $this->makeWidget($this->panels, $name);
 }

  private function makeWidget(array $widgets, $name)
  {
    if (! isset($widgets[$name]))
    {
      throw new InvalidArgumentException('You tried to make a nonexistent widget');
    }

    return new $widgets[$name];
  }
}

class QtFactory extends WidgetFactory
{
  private $button = [
    'button' => QtButton::class
  ];

  private $panels = [
    'panels' => QtPanels::class
  ];

  function __construct()
  {
    parent::__construct($this->button, $this->panels);
  }

}

yayuj started a new conversation Testing A Method That Calls Other Method • 3 years ago

I'm wondering, how do I test a method that calls other method? Is it better to expect a certain result from the other method or expect that the method is going to call the other method?

I'm in this situation: I have an abstract class, and that class has two public method, and one private, the two public methods calls the private one. I can mock the abstract class and pass it to the invoke method of the reflection, but if I try to expect a method of the mock to be called, it doesn't work.

abstract class Foo
{
  public function A()
  {
    $this->C('foo');
  }
  public function B()
  {
    $this->C('bar');
  }

  public function C($arg)
  {
    //...
  }
}

// test
$foo = $this->getMockForAbstractClass(Foo::class);
$method = new ReflectionMethod(Foo::class, 'C');
$method->setAccessible(true);
$foo->expects($this->once())->method('C')->with('foo');
$method->invoke($foo, 'foo');

It doesn't work. - Is it possible? What is the best choice?

4th February, 2015

yayuj left a reply on Mysterious 100% Test Coverage • 3 years ago

Yes, also.

yayuj left a reply on Mysterious 100% Test Coverage • 3 years ago

But I'm doing this, the part where I'm confused is the factory. This part I understand that I can use @covers to cover a method, as you are doing, but what about the new dependency of ``PizzaFactorywhere I'm testing a concrete classGreek`? I mean, how can I mimic the behavior of the factory and don't use the concrete class?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.