Skip to main content

Home/ Coders/ Group items tagged code-patterns

Rss Feed Group items tagged

5More

Design Patterns: 15 Years After the Revolution, by Danny Kalev @ InformIT [2009-10-30] - 1 views

  • by defining a description template that included among the rest: Known uses. Sample code (as opposed to a typical algorithm which were often described in plain English and perhaps a few sketchy lines of pseudo-code). Collaboration (A description of how classes and objects used in the pattern interact with each other). Consequences (results and side-effects). Related patterns.
  • Would a 2009 catalog of the 23 classic design patterns look much different? According to the authors of Design Patterns: Elements of Reusable Code, the answer is no.
  • The authors would reclassify certain patterns and omit a few of the original patterns but the design and implementation would remain pretty much the same: "We have found that the object-oriented design principles and most of the patterns haven't changed since then" says Erich Gamma. You can't escape the feeling that patterns are frozen in time
  • ...2 more annotations...
  • In the meantime, in the C++ world the tide has turned towards a completely different paradigm known as generic programming (and to some extent, functional programming). Instead of plain classes and a complex inheritance chain, C++ these days uses templates, meta-programming and static type checking. The C++ Standard Library is the most prominent showpiece of the generic and functional programming idioms.
  • Over-engineering is another source of criticism. Programmers who become acquainted with patterns are often tempted to solve every problem using a pattern, even when a much simpler solution would probably be a better choice.
1More

Design Patterns in WordPress: We're Just Getting Started - 0 views

  •  
    The thing about design patterns is that there is a wide variety of them and it would be near impossible to do justice to each of the patterns in a series here on the blog. Nonetheless, hopefully taking a look at these three have helped kickstart your interest in using design patterns in your work.
7More

Classical Inheritance in JavaScript - 0 views

  • function ZParenizor2(value) { var that = new Parenizor(value); that.toString = function () { if (this.getValue()) { return this.uber('toString'); } return "-0-" }; return that; }
    • Matteo Spreafico
       
      This constructors lies, wondeful!
  • Again, we augment Function. We make an instance of the parent class and use it as the new prototype. We also correct the constructor field, and we add the uber method to the prototype as well.
  • This adds a public method to the Function.prototype, so all functions get it by Class Augmentation. It takes a name and a function, and adds them to a function's prototype object.
  • ...3 more annotations...
  • To make the examples above work, I wrote four sugar methods. First, the method method, which adds an instance method to a class. Function.prototype.method = function (name, func) { this.prototype[name] = func; return this; };
  • JavaScript can be used like a classical language, but it also has a level of expressiveness which is quite unique. We have looked at Classical Inheritance, Swiss Inheritance, Parasitic Inheritance, Class Augmentation, and Object Augmentation. This large set of code reuse patterns comes from a language which is considered smaller and simpler than Java.
  • I have been writing JavaScript for 8 years now, and I have never once found need to use an uber function. The super idea is fairly important in the classical pattern, but it appears to be unnecessary in the prototypal and functional patterns. I now see my early attempts to support the classical model in JavaScript as a mistake.
7More

Use your singletons wisely - 0 views

  • I know where you live anti-pattern
  • Liskov Substitution Principle
  • the easier it is to test a class, the more likely a developer will test it.
  • ...3 more annotations...
  • Don't worry: the code will always tell you what to do. Just listen.
  • The key points here are that a class is only a singleton if all applications treat it exactly the same and if its clients can use the class without an application context.
  • "[c]ode wants to be simple."
  •  
    "singletons are unnecessarily difficult to test and may make strong assumptions about the applications that will use them [...] I know where you live anti-pattern [...] Liskov Substitution Principle". "To decide whether a class is truly a singleton: * Will every application use this class exactly the same way? (exactly is the key word) * Will every application ever need only one instance of this class? (ever and one are the key words) * Should the clients of this class be unaware of the application they are part of?"
1More

Code Contracts - MSDN DevLabs - 0 views

  •  
    Code Contracts provide a language-agnostic way to express coding assumptions in .NET programs. The contracts take the form of pre-conditions, post-conditions, and object invariants. Contracts act as checked documentation of your external and internal APIs.
1More

GUI Architectures, by Martin Fowler, 2006 - 8 views

  •  
    Extensive description & history of GUI design patterns, of which MVC & MVP.
1More

Gibraltar monitors errors and usage so you can build rock solid .NET software - 1 views

  •  
    The bottom line is that with Gibraltar you go from just logging on the user's computer to sending those logs via a web-service (or email), to reporting on errors and usage to graphing usage patterns, performance trends and feature use... Get real insight into what happens when your customers meet your code.
1More

Refact your C# Code: NCQRS - 0 views

  •  
    NCQRS is a framework implementation of CQRS pattern to separate data modifications operations from data query operations!
2More

« Big Ball of Mud » (aka. Spaghetti Code) , by Brian Foote and Joseph Yoder (... - 3 views

  • The class of systems that we can build at all may be larger than the class of systems we can build elegantly, at least at first.
  •  
    « While much attention has been focused on high-level software architectural patterns, what is, in effect, the de-facto standard software architecture is seldom discussed. This paper examines this most frequently deployed of software architectures: the BIG BALL OF MUD. A BIG BALL OF MUD is a casually, even haphazardly, structured system. Its organization, if one can call it that, is dictated more by expediency than design. Yet, its enduring popularity cannot merely be indicative of a general disregard for architecture. »
1More

Why Singletons Are Controversial - google-singleton-detector - A brief explanation of t... - 0 views

  •  
    * Introduce a global state in the program, hide the dependencies. * Test-driven development: classes become tightly coupled with the singleton. Need to test the singleton along with the class to be tested initially.
3More

Policy Injection App Block - Behind the Scenes - 0 views

  • We use an interception mechanism to get in the way of calls going to that member, collect a list of policies that apply using a matching rules mechanism, run the chain of handlers specified by those policies in a chain of responsibility and at the other end dispatch the call to the target. Once the target is done - successfully or with exceptions - the stack unwinds, returning through each handler and finally back to the caller.
    • Joel Bennett
       
      So we can only advise "before"
  •  
    Very good read (particularly their evaluation of weaving methods).

    Although as a result their "Policy Injection" application block isn't as powerful as most of the straight-up AOP toolkits out there, it does have a *huge* upside: not only is the code produced by this supportable by Microsoft Product Support, it's now officially part of the Patterns and Practices recommendations!

    The down side is that the only injectable objects are ones created through a "Factory" method (you can't just use the *new* constructor) this brings some performance hits ... but then, you get the ability to separate concerns and apply policies and even business rules after the fact!
1 - 19 of 19
Showing 20 items per page