Saturday, November 2, 2013

Transactions are a Business Concern

Transactions are not a persistence concern, they're a business concern. As such, DAOs shouldn't be transactional, your service layer should be.
- Barney http://www.briankotek.com/blog/index.cfm/2008/1/11/Thoughts-on-Adding-Nested-CFTRANSACTION-Support-to-ColdFusion

...typically you want service method to behave transactionally instead of just DAO methods - if you have 2 updates in service method and second one fails, transactions don't help you to have DB consistent (but it depends on your business logic)
- Betlista http://stackoverflow.com/q/10298483

Update: Unrelated but the notion that "business concerns" or "business/domain logic" belongs in a "service layer" may boil down to semantics that are directly dependent on architectural style chosen, e.g. SOA vs DDD (see discussion at http://programmers.stackexchange.com/questions/218011/how-accurate-is-business-logic-should-be-in-a-service-not-in-a-model).

Saturday, October 26, 2013

Downside of Law of Demeter

Author indicates pass through methods (or new parameters added just to pass through?) are a necessary evil of LOD:

The downside is a number of "pass through" methods that do nothing but forward the message to the next child object... Like many OO guidelines, it's probably impossible and impractical to follow this one 100% of the time. The balance between spreading knowledge and adding overhead is a judgment call but I generally vote for more encapsulation until the overhead becomes too painful. 
http://www.ccs.neu.edu/research/demeter/demeter-method/LawOfDemeter/LawOfDemeter.htm

Sunday, September 15, 2013

Mutability Key to Imperative Logic

The only reason imperative logic (a.k.a instructions) execute in sequence is that due to the presence of mutable stored values, the result is dependent on the evaluation order. Using your vocabulary, an "instruction" can (and a "rule" cannot) operate on mutable values. – Shelby Moore III
http://stackoverflow.com/questions/602444/what-is-functional-declarative-and-imperative-programming

Saturday, September 7, 2013

Two-tier vs. N-tier

Two-tier approaches, while allowing more rapid development, are inherently less scalable than N-tier solutions (such as Web-based database solutions).[citation needed] In a two-tier solution, there must be one connection to the database for each concurrent user, whereas with N-tier solutions, which incorporate connection-pooling technology, a limited number of database connections - sometimes, just a single connection - are multiplexed among a much larger number of actual concurrent users.
http://en.wikipedia.org/wiki/PowerBuilder

Sunday, September 1, 2013

Law of Demeter

The issue here is that LoginPage is breaking a the Law of Demeter. LoginPage is asking for the Database even though it itself has no need for the Database (This greatly hinders testability as explained here). You can tell since LoginPage does not invoke any method on the Database.

Sunday, June 30, 2013

Separating Programming from Presentation

"In other words, Velocity doesn't remove programming from presenation; rather it requires users to learn a new ad hoc scripting language. By requiring Web page designers to learn the Velocity Template Language, Velocity fails to eliminate the mingling of the content and presentation." http://www.learningace.com/doc/5903174/2b2d80be66064d5c810bebcd444b927c/j-jsptags

Tuesday, June 11, 2013

Oracle Subqueries

Use a subquery to populate the column, and specify the value that you want returned for a missing value (except if you have Oracle, because its Subquery processing is even worse than its set processing).

http://stackoverflow.com/a/4358687/2066936

Sunday, May 26, 2013

REST vs. SOAP

REST seeks to maximally leverage HTTP to give programs access to web content, and is usually set in contrast to SOAP-based web services, which just tunnel remote procedure call style services inside HTTP requests and responses.
http://stackoverflow.com/a/1077489/2066936

Friday, May 3, 2013

Rules Should be Based on Facts


What the documentation advocates is that you should not call one rule from another, instead, each rule should produce an outcome, and the outcome itself should trigger the next rule in chain. This way rules do not concern with what happens next, and instead they deal with facts (aha!). And if - instead of writing rules for facts - you focus on writing an ordinary flow of procedural logic, you do not really need the added complexity of a rules engine.
The difference is subtle, but not more subtle than rules like "don't put your business logic in view" or "don't put your database access code in your business logic".

 http://stackoverflow.com/a/7247643/2066936

ASP.NET MVC 3 - Client and Server Side Validation

Out of the box:

Notice how client-side validation is still working nicely. We did not need to enable client-side validation manually in the template as before, this is because ASP.NET MVC 3 already has it enabled by default. We did also hide the "Back" button on first step using javascript. We cannot submit the form until all information is correct. Even if a user bypasses javascript validation (which can be easily done), the form will be re-displayed again.
http://afana.me/post/create-wizard-in-aspnet-mvc-3.aspx

Friday, April 26, 2013

Maven - the "Convention over Configuration" Disadvantage

The Maven approach reduces the JAR-file bloat that consumed most version-control repositories. But using Maven encourages you to adopt its "convention over configuration" approach to building software, which can limit your flexibility in customizing your build scripts.
http://www.ibm.com/developerworks/java/library/j-ap05068/

Saturday, April 20, 2013

Significance of the Mach Kernel

 Unlike traditional systems, under Mach a process, or "task", can consist of a number of threads. While this is common in modern systems, Mach was the first system to define tasks and threads in this way. ... The existence of ports and the use of IPC is perhaps the most fundamental difference between Mach and traditional kernels.
http://en.wikipedia.org/wiki/Mach_(kernel)

Saturday, April 13, 2013

Singleton in the cluster

Even my device control JMX mbeans support high availability where they are automatically managed to run as a singleton in the cluster.
http://humbleblogger.blogspot.com/2005/04/aspnet-vs-j2ee.html

Message Persistence

Also, with async-style RPC there's no equivalent to message persistence - which when message persistence is coupled with transaction semantics, it enables messages to be reliably processed (think credit card transactions, etc).
http://humbleblogger.blogspot.com/2005/04/aspnet-vs-j2ee.html

Wednesday, March 27, 2013

prototype members should be methods

You want the members of prototype objects to be methods. Adding objects which itself contain methods doesn't sound like a good pattern. – Šime Vidas http://stackoverflow.com/questions/8693279/javascript-accessing-parent-properties-from-inside-nested-function

Tuesday, March 26, 2013

JSON.stringifying a Circular Reference

You can use the replacer function approach to blacklist member names (in contrast to how the replacer argument as an array whitelists member names). I’ve found this approach to be useful when I need quick and targeted logging of certain values from a DOM element, but I want to prevent a serialization exception due to attempting to serialize a circular reference (which would occur if I drank some antifreeze and attempted to do something ridiculous like JSON.stringify(document.body)). 
http://freshbrewedcode.com/jimcowart/2013/01/29/what-you-might-not-know-about-json-stringify/

Friday, March 22, 2013

Refactoring is an Art

Which Choice should we work on first? Should we move logic to A first and then B, or B first and then A? How much do we work on one Choice before moving to the next? What about other refactoring opportunities we see as we go along? These are the kinds of succession questions that make refactoring an art.
Kent Beck

Mixins in Ext JS 4 - On why mixins are useful

Mixins are really useful when a class needs to inherit multiple traits but can’t do so easily using a traditional single inheritance mechanism. For example, Ext.Windows is a draggable component, as are Sliders, Grid headers, and many other UI elements. Because this behavior crops up in many different places it’s not feasible to work the draggable behavior into a single superclass because not all of those UI elements actually share a common superclass. Creating a Draggable mixin solves this problem – now anything can be made draggable with a couple of lines of code.
http://edspencer.net/2011/01/classes-in-ext-js-4-under-the-hood.html

Sunday, February 3, 2013

Relational DB and Everyday Users

Unfortunately, the mathematics of relations escapes most everyday users of databases, and the quest for ease-of-use amounts to little more than a tradeoff between representational power and simplicity. For example, relational systems for everyday users rarely allow true relational joins, and many can only use a single table at a time, even though the representational utility of the model fundamentally relies on ability to decompose relations into multiple "normalized" relations. 
http://www.freepatentsonline.com/5283894.html

Reminds one of the SharePoint "phenomenon"