Wednesday, October 31, 2012
Using a module to share common association logic in Rails
I recently wanted to DRY up some repetitive Rails association code, similar associations used in multiple models. This gave me the opportunity to figure out a few tricks, like creating a module Class method and using metaprogramming to add dynamically named accessors.
Anyway, here is the Module:
...and the client model...
Tuesday, August 28, 2012
An old crack at a stream processing framework. WAS: Building procedures with composition
Often developers need to model a multi-step process. Also common is the need to reuse pieces of the process: maybe the steps are the same but the execution of the steps vary for different contexts, or maybe the step flow changes slightly in some cases but the logic of the steps is largely reused.
One common way developers address this situation is to implement a Template Method pattern. For example, an insurance system might have several similar flows for processing feeds from different sources--partner EDI, consumer web site, provider applications--where many of the steps involved are largely reusable.
A Template Method basically uses inheritance to share common logic, while varying the implementation of steps by overriding methods representing particular steps. However as the GOF posited and leading developers believe today, one should "favor composition over inheritance." Inheritance abuse is a common and natural side effect of trying too hard to reuse logic the OO-way, but we can do better.
The essential problem with using inheritance with the Template Method is that the class tree can get pretty ugly if one needs to vary the implementation of steps AND the flow of steps. Also, more often than not, the is-a relationship between common and specialized processors is restrictive and faulty. For example if a processor implementation wanted to extend something else like ActiveRecord.
What if, rather than using a template method, one could compose flows of steps, where the steps are pluggable members? Another way to build processes that can be reused and extended is with the Strategy pattern, where the algorithm (or steps thereof) are pluggable. Using this approach, the developer creates the structure of the flow in one class but delegates the execution of steps to collaborators.
Now what if there was a fluent interface for building flows of plugable steps, as well as machinery and conventions for coordinating between steps? Well, that is the idea of Flo: https://github.com/jtroxel/flo
Some of the ideas from Spring Batch and Apache Camel have also inspired my thinking here, but Flo is much simpler and less specialized. I was also motivated by the Unix programming model, little tools that do one thing well, strung together with pipes.
Note that Flo is a work in progress, awaiting her first real application.
Monday, June 18, 2012
Controlling Rails mass-assignment with whitelists and :as
whitelisting and roles: https://gist.github.com/2948700
Tuesday, June 12, 2012
Objects in Practice - Testing Objects
Tuesday, November 29, 2011
Search as Data Store
In poking around, I've found that it is not unheard of to use SOLR as a web backend. Perhaps the most prominent example would be The Guardian's use of SOLR for their "Content API." There was also supposedly a twitter-like example that "uses the Lucandra store exclusively and does not use any sort of relational or other type of database", though the link did not work as I wrote this (Lucandra is the predecessor to Solandra).
Why not just stuff everything into SOLR? It is effectively a document store with powerful and fast queries. Sure it does not support transactions and the data is not normalized in a relational sense. But do you need those things for content? What I mean by content is dynamic stuff that might be edited by humans or updated by feeds: articles, comments, tags, product descriptions, locations; data that is viewed a lot but edited infrequently, not super structured or requiring crazy integrity. With the Cassandra backing, you should at least get durability and eventual consistency on the data that you shove into SOLR (Solandra).
I guess now I will have to give it a try, see where the trade-offs are in practice between search, NoSQL, and Relational stores on a real content project. Who's got one for me? :)
Tuesday, November 15, 2011
Objects in practice: class basics in Java and Ruby
For this post, we are modeling employees of a software company, something like:
(via YUML:
edit)
NOTE: This is NOT a good design--doesn't allow employees to fulfill multiple roles, doesn't account for changes over time--but I'll show better designs in later Howtos.
So, the general idea is that we want to reuse some behavior and also provide some specialized behavior. Probably the most simplistic way to do this in OO languages is to set up concrete inheritance and leverage polymorphism. I'll show how this is done in Java and Ruby, and the complete code can be found at github
JAVA
A simple parent class, provides startDate member and monthsOnJob to subclasses:
public class Employee {
private Date startDate;
public Integer monthsOnJob() {
Integer months = 0;
// Do the math
return months;
}
public String jobDescription() {
return "New employee"; // Default description, will be overriden by subclasses
}
}
A simple subclass, adding behavior to the super and overriding the description
public class Developer extends Employee {
@Override
public String jobDescription() {
return "Developer: " + listTechnicalSkills();
}
private String listTechnicalSkills() {
String skillStr = "";
// TODO get skills from getTechnicalSkills and build string
return skillStr;
}
private Collection technicalSkills;
public Collection getTechnicalSkills() {
return technicalSkills;
}
public void setTechnicalSkills(Collection technicalSkills) {
this.technicalSkills = technicalSkills;
}
}
Another specialization, Manager has Employees as reports
public class Manager extends Employee {
Collection reports;
@Override
public String jobDescription() {
return "Suit";
}
public Collection<Employee> getReports() {
return reports;
}
}
Ruby
Now the parent class in Ruby
class Employee
attr_accessor :start_date # method that creates accessors
def initialize(start)
@start_date = start
end
def months_on_job
# Math is easy
(Date.today.year*12 + Date.today.month) - (@start_date.year*12 + @start_date.month)
end
def job_description
"New employee"
end
end
A Ruby Developer class
class Developer < Employee
attr_accessor :technical_skills
def initialize(start)
super(start)
@technical_skills = []
end
def job_description
ret = "Developer: "
@technical_skills.each {|skill| ret << " ${skill"}
end
end
The Manager
class Manager < Employee
attr_accessor :reports # accessor
def initialize(start)
super(start)
@reports = []
end
def job_description
"Suit"
end
end
Monday, October 24, 2011
John's Independent Forray v3.0
This time around I am going by codecraft solutions. I am presently subing with Marty Haught and intend to continue for some time. Eventually though I intend to run my own projects too.
That's the plan, stay tuned.
Wednesday, September 20, 2006
What's So Great About Rails?
It is still Web programming, there are no major paradigm shifts here. However, Ruby on Rails is an example of how a lot of little things done right can really add up. Ruby is a fine scripting language, improving upon popular languages like Perl and Python. And Rails is an example of getting the little details of Web programming right. Rails is optimized (as I see it) for (1) Productivity and (2) Maintainability. The following are what I really like:
- The clean, simple ActiveRecord ORM layer.
- A full-fledged yet simple MVC that is easy to comprehend and get around in.
- Sensible defaults and very little configur-bation; "convention over configuration."
- A good job of making the most common tasks simple; the 80/20 rule.
- "rake migrate" is the coolest way to manage schemas that I have seen.
So I do like Rails a lot, I think it is probably the best solution for many small-medium sized webapps. But it is not necessarily a replacement for Java, especially in the enterprise. The trick is for decision-makers to weight their needs for big E Enterprise requirements against speed and simplicity.
Tuesday, September 19, 2006
Productive Editing and Eclipse
The talk was a bit of a wake-up for me. His premise is that the rise of the IDE has made programmers, well, lazy (my words, I don't think he went so far). I realized that I have let some old but valuable skills languish in the past few years. So Neal's talk has inspired me to sharpen the saw back up. For example, I have made the decision that Ruby will be my scripting power tool moving forward (used to be Perl), and I will not shy away from opportunities to explore automation (even if it is initially just exercise).
Another point that resonated with me was the idea of the "perfect" editor. I do think that I am now as productive over all in Eclipse as I used to be in Emacs (with a side trip through NetBeans). But Neal hit on two things that are missing: Multiple cut/paste buffers (kill-loop in Emacs) and editor scripting. Though I am intrigued by the lightweight JEdit, I am determined to stay in Eclipse and make the best of it. I think that surely these two deficiencies can be addressed.
On the multiple buffers front, I quickly came up with an answer that works for me: CLCL. This tool is actually a utility that caches your Windows clipboard. So CRTL-C still works like normal, but you can also reach back in time and paste something from 30 cuts ago. Sounds trivial, but it can change the way you edit.
As for the scripting integration, I haven't looked very far. Prashant Rane's blog led me to Eclipse Monkey, which looks interesting--it's Javascript, which I can defnitely code. I might keep looking, though, for something that provides editor hooks for Ruby, Groovy, or BeanShell. I'll post again if I find the silver bullet.
Thursday, April 27, 2006
Shameless Promotion 4: Rapid, Affordable Application Development
I have built dozens of successful applications for the Web and other environments. I can provide hands-on expertise across the software development lifecycle: from strategy and requirements to architecture and design to development and testing. I also provide project management and "general contractor" services, so I can bring the right talent to the table for most any web development project.
The following is a quick summary of the skills and capabilities I provide to help you achieve robust solutions quickly and at affordable rates:
- Experience in online communication, eCommerce, and improving efficiencies.
- Technical lead, architect, and developer experience on dozens of projects, including complex applications for Sheraton Hotels, Travelocity, Budget Rent-A-Car, and the Veteran's Administration.
- Programming experience in Java (5+ years), C (3), VB/ASP (3), Perl (2), and lately Ruby.
- Effective, hands-on skills as a software engineer, architect, and business/systems analyst.
- MBA and a Bachelor's in Computer Science.
- Extensive network of software and Design professionals for general contracting services.
- Very competitive rates, for myself and subcontractors.
My Resume describes my skills in much more detail. I'd love to make your development project a huge success, drop me a line if you are interested.
- John
Wednesday, April 26, 2006
Software Success Factor #1: Manage for Agility UPDATED
What

Iterative development is perhaps the key attribute of modern software success, but without management support it is impossible. To manage for agility, leaders must go against many traditional management styles and ingrained practices. It is a natural for successful business people to try to avoid future change through detailed planning and up-front analysis, but changes are inevitable. Trusting the team and the process to produce the best solution, allowing the scope, the design, and even the process to emerge, is what it means to Manage for Agility.
How
To manage agile projects, sponsors must resist the desire to plan and design the entire project before starting any development. To be agile, management must instead embrace a flexible model that responds to changing requirements and an evolving understanding of the solution. Management must trust the process and the team to produce top quality software, without a relying on a rigid scope.
Often it is the "commercial Model," contracts, SOWS, etc., that most influences the interaction between management and the project team. To manage for agility, the commercial model must provide for evolving scope and design. Put another way, attempting to fix the scope in agreements up-front is simply at odds with an agile style. When using consultants or contractors, a Time-And-Materials approach allows for the most agility, or the agreement can employ separate SOWs created at the start of each iteration. Another approach offered by Kent Beck is the use of "Optional Scope Contracts."
It is also important to understand that agile does not mean that no planning or requirements are done up front. The project still needs a first cut at the inventory of requirements--e.g. a Scrum backlog or a Use-case survey--that is the source from which iteration requirements are selected, refined, and built. An agile project can also develop a detailed, "pro-forma" project plan, but managers should not feel compelled to stick to the original as the team adjusts to accumulating change.
Why
Why should managers buy into this approach, when traditional project management techniques have worked on all kinds of projects, from construction to aerospace engineering? Because software development is fundamentally different from construction or engineering, and treating it like these disciplines magnifies the risk of failure, raises costs, and produces worse software.
Change is unavoidable in Software Development, more so than most any field. Alan Shalloway made the claim, at a recent Agile Denver meeting, that software development is not like building a bridge; it is more like building the first bridge... or the design phase of a bridge project. An analogy is also often drawn between construction and software development. However, many experts claim that software development is essentially all design work, and the only step that is really like construction is the compile/build cycle.
The highly successful Scrum process is based on proven new-product development processes used by Japanese companies. Indeed, the Scrum proponents and many others have claimed, accurately I believe, that software development is very like new product development. If we look at software development as roughly analogous to the design and development of a new kind of car, or a new consumer electronics gadget, it becomes clear that the nature of the process is unpredictable and should be managed accordingly. Agile management uses an empirical process management approach to produce a better product. One need look no further for evidence than the difference between American cars and Japanese, at least until very recently.
Alistair Cockburn expands on the idea of "responding to change over following a plan:"
...traditional process management—by continuous measurement, error identification, and process refinements—strove to drive variations out of processes. This approach assumes that variations are the result of errors. Today, while process problems certainly cause some errors, external environmental changes cause critical variations. Because we cannot eliminate these changes, driving down the cost of responding to them is the only viable strategy. Rather than eliminating rework, the new strategy is to reduce its cost.
[NOTE: I think he means code rework--Big Up-Front planning and design will result in more rework of other work products, assuming the effort is not wasted entirely as these products are abandoned.]
Business needs, priorities, understanding of user needs, expertise with the
technical platform, market forces, and available technologies... All of these
can and usually do change over the life of a project. Agile management rolls
with these changes and capitalizes on them to make the best software possible.
Smart project sponsors can use agile management to build better software for
less money.
Friday, April 14, 2006
The Software Success Reference Model - Overivew
Groupings
Organization and Project Management
Perhaps this should be entitled simply Organization and Management. This grouping deals with factors that are beyond the scope of any project team--organization and management at the highest levels.
Project Team
These factors deal more specifically with the project team involved directly with producing the software.
Iterative Development
This category contains factors that relate to producing software in an iterative, incremental, adaptive manner.
Productive Culture
Factors dealing with the kind of people the Organization employs and how the Organization fosters a culture that promotes productivity.
Productive Practices
Specific practices that help the Project Team develop software efficiently.
Software Engineering (for Large Projects)
Factors necessary for projects with a large number of developers and/or critical consequences of failure.
Factors
Manage for Agility
This factor encompasses the critical role that Management--or the Client--plays in Iterative Development. Leadership must be willing to launch a project without detailed plans or specs, and trust the team and the process. Further, project clients must realize that the agile approach is a Good Thing, allowing the team to respond nimbly to a changing world, and producing more relevant software in less time.
Deliver Value Quickly & Often
Another aspect of Iterative Development, this factor focuses on the ultimate goal of software development: working software. Teams must focus on producing working software from the very first iteration, and keeping implementation as relevant to the needs as possible by avoiding unnecessary interim work products and long time lags.
Continuously Learn & Optimize
The final component of Iterative Development is the concept of continuous improvement. Iterations afford the team with the opportunity to exercise all lifecycle activities in short bursts. This means they can reflect, learn, and optimize their process and practices with each cycle.
Empower the Project Team
Also solely in the Management arena, the client of the project must provide the project team with the tools, resources, and support necessary to succeed. As much as possible, the team must be allowed to organize and direct itself however necessary to deliver the requirements.
Enable Open Communication
Software development is inherently a team design activity. Communicating ideas and building a shared mental model of the solution are critical. Organizations must strive to achieve "osmotic" communication, provide access to experts, and involve users throughout the process.
Demand Quality
Teams must develop a high standard of quality as a norm, and internalize quality validations within the team, rather than "throwing" code "over the wall."
Use More Realistic Specification(s)
Just as a picture is worth a thousand words, the richer, higher-fidelity one can achieve in software specifications the better. Teams should use mock-ups, prototypes, and visual models as much as possible, while still constraining specification to whatever is "minimally sufficient" for the current increment.
TODO: Software Engineering factors
Thursday, March 02, 2006
Software Development Success Reference Model - Background
About 6 months ago, I started trying to create a set of success factors that were synthesized from the experts. I have since completely revamped my thoughts. What I ultimately want, for my own purposes, is a "Reference Model" (e.g. the OSI 7-Layer Model) that provides some structure with which I can I can think and talk about the various factors that lead to success--independent of any specific methodologies. I hope to be able to say things like "Reflection Workshops in Crystal are one technique to Continuously Learn and Optimize," or "XP provides a system for Iterative Development and Proven Practices, focused on smaller Project Teams."
I have now spent some more time thinking, and included some more popular, respected sources. The following slide is my Reference Model, a 30,000 ft. view of software success.
In future posts, I will provide more details on the individual success factors and how they relate to the work of industry luminaries. So, how did I arrive at this model? I started by taking the most important, highest-level principles and factors from the following excellent resources:
- The Standish Group's CHAOS study [CH1..9]
- The Unified Process or RUP [RUP-1..6]
- The SCRUM meta-process (web, book) [SC-1..4]
- Alistair Cockburn and Crystal methods (web, book, book) [AC-1..7]
- eXtreme Programming (web, web, book) [XP-1..5]
- My own experience on dozens of successful projects [JT-1..6]

Comments are most welcome.
Wednesday, January 11, 2006
New Frontiers of Enterprise Java Development
Background:
In the mid-90s, the ubiquitous distribution and instant maintenance capabilities of Web-based applications pushed them to the forefront. When applications moved beyond brochure-ware, a significant problem arose: Teams developing Web-apps could not readily achieve the enterprise requirements, or qualities, necessary for success: performance, scalability, security, etc. So, most of the effort and money spent by development teams went to achieving the necessary enterprise qualities.
Teams also struggled with process in the 90s, and to a large extent still do. The fast and loose style of early Web development did not work for mission critical apps, and traditional Methodologies did not work for Web teams. Furthermore, I think the frenetic rate of business and technical change finally killed the notion of viability of traditional, waterfall processes, at least for shops that "got it. "
By the late 90s, the major Web application platforms, like J2EE and compliant app. Servers, made it practical to address Enterprise requirements--although not easy or efficient. In addition, the effects of Moore's Law have made it much cheaper to throw more hardware at a solution, reducing the effort involved to handle the scale of enterprise apps. At the same time, Agile project management approaches began to gain visibility, blending the engineering-like discipline with the creative nature of software development.
In 2006, I contend, the development tools and frameworks for Web development have largely caught up to the platforms. Creating a robust, scalable, enterprise app no longer necessitates an army of J2EE coders rolling EJBs by hand. Looking forward, ISVs and IT shops just don't have to focus as much on addressing enterprise requirements*. Nor do teams need to struggle with heavy Methodologies--there are new mountains to climb. It is time for Web application development to grow up and act like "real" product development.
Competing with Agile Project Management:
Today, I think any manager who doesn't at least vaguely acknowledge the benefits of an Iterative or Agile project management approach has been hiding under a rock for several years. Some managers even claim to use these approaches, although few really do it right. Just because a team breaks up the coding for a project into increments, doesn't mean that they are Agile.
To improve productivity with process, management must get away from the compulsion to scope, define, and plan the entire project up front. Rather, they must accept and embrace two essential facts:
- Needs and requirements will change constantly during the project; and
- User needs, technological pitfalls, and team capabilities will never be adequately or accurately understood until the team has gone through the complete lifecycle with one or more slices of the working system.
Yes, it's a catch-22 situation: Managers have to accept that reality. Managers must embrace change, accept the empirical nature of the software development process, and stop trying to do all the planning and specification work up-front. Companies still trying to use linear, silo'd, paper-heavy methods for Web-based apps are dead, whether they realize if or not. To increase productivity, and reduce costs and time-to-market, managers must truly understand and utilize Agile management. I personally think that Alistair Cockburn's work on Agile development is the most comprehensible. Scrum is perhaps the best overarching management view, and XP provides a system of proven team practices.
Another project management "move" that can greatly reduce development cycle times is rapid prototyping. Simply put, exploring and defining requirements with documents is a relatively poor way of getting the system right. More productive projects user "richer" media for definition and validation, and the richest vehicle is a working prototype. For example, a team can develop a Ruby on RAILs prototype to quickly and cheaply explore and validate the functional requirements. Another powerful option for rapid prototyping and validation is Gorilla Logic.The working prototype provides much more comprehensible, complete, and unambiguous information than stacks of documentation, which saves a ton of wasted work downstream. If one accepts that an iteration or increment can be thrown away, then prototyping fits very nicely with Agile methods.
Though not strictly a project management move, I also think that automation has tremendous potential to make teams more competitive. That will be the subject for another post. For now, I will simply say that I think that XDoclet is definitely a tool that teams should look at using and extending... and MDA tools like AndroMDA show some potential as well.
Competing with Richer User Interfaces
Along with the powerful distribution and update benefits of the Web came with a catch: The capabilities of a browser-based interface, though often visually attractive, are weak. Things like tree browsers, master-detail views, and fine control over interface widgets have generally been painful to achieve. Teams did not have time to work around these issues, and the user experience suffered.
Now that the technologies are available that help to take care of enterprise issues with much less effort, teams can make there applications better with richer user interfaces. AJAX, a technique for making asynchronous HTTP requests in the javascript for a page, seems to be a very hot technology of late. For applications that require a highly graphical look and feel, along with better usability, Macromedia Flex is strong player. But the next great client platform, I believe, is Eclipse RCP.
*NOTE: I also think that tools Ruby on RAILS, PHP, ColdFusion, etc. might now present a viable challenge to J2EE and .NET in the Enterprise space, with the right hardware.
**NOTE: I really don't have a feel for what is going on in the Microsoft/.NET world. However, to their credit, I think Microsoft has always focused more on productivity than on Enterprise requirements (e.g. VB). How successful they have been on this front is a matter of debate.
Thursday, December 01, 2005
Implementing the Value List Page Iterator Pattern
I have come across a situation that warrants the use of the "Value List Page Iterator" pattern. First off, the official name is the "Value List Handler," previously known as the "Page-by-Page Iterator." The pattern is part of the Core J2EE Patterns from Sun. I have chosen to use the name "Value List Page Iterator" because the other two names miss the main points: iterating over a value list grouped into pages. The context is situations where a query can return more results than can be presented on one screen, the solution is to allow the user to page through results, like with your typical Web search engine.
The code part of the pattern is simple enough, and the data access is nothing fancy--as long as the query is pretty quick, and/or it is acceptable for the app to keep all the results in memory. In my case, the query takes minutes and can return potentially millions of results. I need something that "slices" the data from the db into manageable chunks. Brad Long of Oracle has written up a pretty comprehensive treatment of database slicing strategies and offers his own variant of the pattern. Brad nails down the best way to do a slicing query, which I have tweaked:
SELECT *
FROM (SELECT ROWNUM RNUM, INLINE_VIEW.* FROM(
your-select
your-where
and key-or-order-by-field > lower-boundary
[order by order-by-field]
) INLINE_VIEW
)
WHERE RNUM < max-range
My current problem is that the row-limited (sliced) query takes just as long as the full query. So unless I can figure out some way to effectively cache the query in the database, I am still faced with either sticking all of the results in memory, or taking the performance hit of executing the query multiple times. I am also thinking about a hybrid solution, where I guess at the most likely initial pages and get those at once, then re-execute the query if the user navigates outside the initial results.
More to come...
Thursday, October 20, 2005
More on Composition versus Inheritance
Bill Venners writes about this in JavaWorld. The key criteria to consider is whether the relationship is really an “is-a” relationship, and just how strong the is-a is.
Make sure inheritance models the is-a relationship [...]
An important question to ask yourself when you think you have an is-a relationship is whether that is-a relationship will be constant throughout the lifetime of the application and, with luck, the lifecycle of the code. For example, you might think that an Employee is-a Person, when really Employee represents a role that a Person plays part of the time. What if the person becomes unemployed? What if the person is both an Employee and a Supervisor? Such impermanent is-a relationships should usually be modeled with composition.
He continues to point out that both code-reuse and polymorphism can be achieved with composition, and should not be a reason to use inheritance without a strong is-a relationship.
java.net hosts a discussion on the topic. A common approach is to code using interfaces, and use concrete inheritance in the implementations--in other words, use composition (with interfaces) in your design, use inheritance (for re-use or polymorphism) in the implementation. The is-a rule would still apply to the implementations, of course.
Friday, October 14, 2005
OO Design Principles: a Quick Rundown
Some of the best wisdom in OO design is captured by the Gang of Four. Artima has an interview with Erich Gamma where he discusses the core principles from the intro of Design Patterns:
Program to an Interface, not an Implementation
Once you depend on interfaces only, you're decoupled from the implementation. That means the implementation can vary, and that's a healthy dependency relationship.
Rod Johnson expands on this idea in Chapter 4 of the pre-Spring book, and provides some very well-phrased guidelines:
Program to interfaces, not classes. This decouples interfaces from their implementations. Using loose coupling between objects promotes flexibility.
...
A few of the many advantages of an interface-based approach include:
- The ability to change the implementing class of any application object without affecting calling code. This enables us to parameterize any part of an application without breaking other components.
- Total freedom in implementing interfaces. There's no need to commit to an inheritance hierarchy. However, it's still possible to achieve code reuse by using concrete inheritance in interface implementations.
- The ability to provide simple test implementations and stub implementations...
Turning back to the Gamma interview...
Favor object composition over class inheritance
Composition has a nicer property. The coupling is reduced by just having some smaller things you plug into something bigger... In a subclass you can make assumptions about the internal state of the superclass when the method you override is getting called. When you just plug in some behavior, then it's simpler. That's why you should favor composition.Mr. Johnson expands:
To clarify the distinction, let's consider what we want to achieve by inheritance. Abstract inheritance enables polymorphism: the substitutability of objects with the same interface at run time. This delivers much of the value of object-oriented design... Concrete inheritance enables both polymorphism and more convenient implementation.
...Interface inheritance (that is, the implementation of interfaces, rather than inheritance of functionality from concrete classes) is much more flexible than concrete inheritance.
Robert Martin is another thought leader on core principles, has defined several core principles including the following:
[NOTE: Still under development]
The Single Responsibility Principle (SRP)
There should never be more than a single reason to change a class... Changes to one responsibility may impact other responsibilities.
Open Closed Principle (OCP)
A module should be open for extension but closed for modification
Should be able to add behavior without modifying common behavior
Liskov Substitution Principle (LSV)
The Interface Segregation Principle (ISP)Subclasses should be substitutable for their base classes
Interfaces shouldn't have stuff that their clients don't need... Factor interfaces so that clients can use just relevant members
The Law of Demeter
Only talk to your friends who share your concerns... Never call a method on an object that you got from another call or on a global object.
http://c2.com/cgi/wiki?LawOfDemeter
http://www.ccs.neu.edu/home/lieber/LoD.html
http://c2.com/cgi/wiki?LawOfDemeterRevisited
The Dependency Inversion Principle
Modules should depend on abstractions, not concrete modules... Details [controllers?] should depend on abstractions, not the other way around.
"Inversion" in contrast to structured, procedural thinking.
Monday, October 10, 2005
Garbage Collection is still important
Simon Roberts delivered a great primer on the topic to the DJUG Architecture SIG last week, we'll try to get slides up on the archive soon.
Friday, September 23, 2005
The Main Things for Software Projects

The preceding is a summary slide from a deck I am using to clarify my own approach to methodology. It is a synthesis of recommendations from the CHAOS report, Alistair Cockburn, and my own experience.
Essentially, I mapped out the lists of "main things," or critical success factors, provided by CHAOS and Mr. Cockburn, and also made my own list. Then I went through an exercise of correlating and consolidating. This is where I ended up.
I think this checklist provides a concise, strategic guide for improving a project's chance of success. More useful still would be individual guides that provide tactical guidance for each of these, probably mapped against key project variables (like Alistair's team size and safety). I'll get right on this in my free time.
I also think it would be interesting to check this list against other similar lists from other modern methodologies like RUP, XP, etc. Rhythm, presented to the DJUG by Brian Boelsterli, looks like an interesting framework that might also have similar factors to consider.
Friday, September 09, 2005
Rapid Prototyping and Development--Options
In this post, I continue my analysis of rapid prototyping for Java Web apps. I see a few essential ingredients necessary for rapid prototyping:
- Fast and simple development of pages and page flow: must be able to easily create pages, get parameters from a submission, do business stuff, go to the next page, and present dynamic data--without manually touching 12 different files.
- Automation of basic CRUD activities: Even in complex apps, so much code fits a basic CRUD template. It is extremely helpful to be able to automate the first cut at this, by specifying model information once in the database, the code, or a neutral spec.
- Quick develop/run cycles: If it takes 45 seconds to see a change to the width of a text field, rapid prototyping is in trouble.
- Extensibility: Whatever cool automatic stuff is done for us, we need to be able deviate from the happy path and customize stuff.
- Anything else I am missing?
Are there Java technologies that allow developers to skip the enterprise stuff initially, and add it in later with a little refactoring?
- JSPs with code in the pages (or Velocity templates w/out the MVC, etc.): Good for 1 & 3, but ignores 2.
- IDE / Graphical tools: E.g. Java Studio Creator (is there a comparable Eclipse plugin?).
- Rife framework:
- Trails framework:
- Model Driven tools: I looked at AndroMDA a while back, and I don't remember it striking me as a tool for rapid prototyping. But it is probably worth another look. Since I started this post, I have come across Gorilla Logic, which looks very intriguing.
Are non-Java tools, e.g. Ruby/RAILs, that allow for development that is so inexpensive that we are willing to throw the prototype away?
- RAILS claims a 10x productivity advantage over J2EE, and judging by their demo it is at least that. So even if Ruby CGI is insufficient for Enterprise requirements, you can create a throw-away that is worth the effort.
To Be Continued...