Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
5

Inheritance is not bad per se. It depends on how you use it. Avoiding a technique just because someone says it is bad is not a good way to make decisions. While I see where Josh Bloch is coming from, the alternative he proposes is not quite the same thing. The Template pattern aims to enforce a particular design; it takes advantage of the rigidity of ...


5

What is a pattern? A pattern is not different from any other code you use in your application. The only difference is that somebody said "this is now called [x] pattern" and then that name has been universally accepted. If I say "Visitor Pattern" to another developer, they might just know what I am talking about. >99% of programming solutions have not ...


2

Your ResourceCommonProcedures doesn't really seem to be an example of the Template Method pattern (as it doesn't really define a 'template' for an operation, except perhaps in a trivial sense). Your base class acts as a factory that produces a concrete ResourceCommonProcedures-derived instance based on an identifying parameter (resourceType). Arguably, that ...


2

There is no hard and fast rules how to handle errors. When an operation could (theoretically) produce an error, you need to look at the situation, each situation individually, and decide how to cope with it. Case 1: Errors that you are convinced cannot happen. Check for them, and in a debug version have an assertion that will stop execution in the debugger,...


1

What you need is a separation between mechanism and policy. You should have model modules that interacts with your data storage and implements business rules. Then these are wrapped with as many modules that implements permissions checks as you needed. As you're using PHP, an additional risk exist that you need to take into account to make sure that user ...


1

Your approach to log every get request even if the information with the current requirements is redundant could potentially prove valuable in the future if requirements change. In that case you simply change your log-filter. Otherwise the audit service seems like a good place to filter events before storing them. This service could maintain an in-memory ...


1

One of the strong selling points of OO is supposed to be encapsulation: the implementation details are hidden away and only API, in the form of method signatures and the like, are exposed to the wider world. Yet there is a well recognised way of breaking that encapsulation: you guarantee that a method will perform certain actions, including calling other - ...


1

Make the generational nature of the data explicit: Create Databox1 from the initial set of values in step 2. Databox1 is immutable. Pass Databox1 to the next stage, producing Databox2; Databox2 either holds a reference to Databox1 or copies all the fields in place. Databox2 is immutable. Pass Databox N to stage N, and produce Databox N+1. The immutability ...


Only top voted, non community-wiki answers of a minimum length are eligible