Tag Info

New answers tagged

4

You are over-using SRP. Let's take a look at mappingConcern's creation-and-initialization version: public function mappingConcern($data) { $parameters = $data; $product = new Product($parameters); return $product; } $parameters is the same as $data, and $product is returned immediately, so it can be translated to: public function ...


3

Why create a whole other classes to handle those responsibilities? Because when you're doing Object Oriented Programming, your focus should be on the objects. They are your unit of work for making the design and providing abstraction. And most importantly, they are your unit of reuse. By letting them change for different reasons, you're forcing people ...


3

I've never seen the point of a class that only queries the database and returns an array (or DataSet or DataTable for those in .NET). The mapping of columns in a database to properties or fields on an object belongs in its own class, not in the constructor. The whole point of a data mapper is to decouple the database schema from the object model. By passing ...


2

The code sample #2 you provided is preferable in my opinion. What if tomorrow you want to have CachedProductData, you would only update product data class, or rather introduce another layer. If you have both classes merged like in example 1, you would be updating both responsibilities. So, Single Responsibility Principal would be broken if you choose ...


0

To be honest, I deal with this issue every time I produce a software design. I learned to do it this way: Minimum Viable Product implemented as close to SOLID principals as possible. Once you feel like you are satisfying every SOLID principal to an acceptable degree(I am yet to see 100% compliance), you did it right.



Top 50 recent answers are included