Thursday, December 01, 2005

Implementing the Value List Page Iterator Pattern

UPDATE: Brad Long's Article is now found here.

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

Is there any more basic OO design decision than this? I started off, like many newer OO programmers, writing code with a lot of concrete inheritance. After some painful lessons and more reading, I now lean heavily toward using composition. So OK. How do we nail down exactly when to use which approach?

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

I wanted to collect some good resources on basic OO design principles, with brief summaries of each, so that I have everything in one place. I hope to ultimately distill these into a one-page "crib sheet.'

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)

Subclasses should be substitutable for their base classes

The Interface Segregation Principle (ISP)

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

I think in J2EE, it is easy to get away from the basics of solid Java programming, assuming that the container will take care of the hard stuff for us. Understanding how GC works, however, can be crucial for J2EE applications, expecially high volume or long running runs. I don't know about you, but I might need to brush up on this stuff.

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:

  1. 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.
  2. 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.
  3. 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.
  4. Extensibility: Whatever cool automatic stuff is done for us, we need to be able deviate from the happy path and customize stuff.
  5. 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...

Rapid Prototyping and Development--Questions

I've been thinking again about rapid prototyping and RAD tools for Web development. Perhaps it is because I have been working with Enterprise apps for a few years, with their focus on hard-core non-functional requirements (security, scalability), but I don't see much going on anymore. It seems to me that J2EE, and the various Java frameworks, are so focused on robustness and maintainability that rapid prototyping is nearly impossible.

In the wild and whacky early days of Web development, it seemed that we got the functional requirements right, but then endured hell when our applications didn't perform or missed the mark on non-functional requirements. Why? Because we did very minimal requirements and immediately dived into scripting pages, essentially rapid prototyping. Now, as I see it, the Web world has inverted this situation: we have to do more requirements because it is more expensive to get working code in front of the user, but the technologies are more robust. I contend that, in general, it has become more difficult to get the functionality right, and that we now have applications that are often over-engineered.

I'd like to figure out how to re-introduce rapid prototyping into the realm of Java Web development. Here is what I think I need to figure out:
  • I see a few essential ingredients necessary for rapid prototyping: Fast and simple development of presentation code, automation of basic CRUD activities, and quick develop/run cycles. What else?
  • Are there Java technologies that allow developers to skip the enterprise stuff initially, and add it in later with a little refactoring?
  • Are non-Java tools, e.g. Ruby/RAILs, that allow for development that is so inexpensive that we are willing to throw it away?

Monday, August 15, 2005

Java Exception Prescription

What are truly the best practices for using Exceptions in Java? Should checked exceptions be the norm? How should the Exception classes be structured? In this posting I attempt to achieve a personal approach to using Exceptions.

In Handling Exceptions from the Sun Java Tutorial, stresses the use of checked exceptions:

If a client can reasonably be expected to recover from an exception, make it a
checked exception. If a client cannot do anything to recover from the exception,
make it an unchecked exception

Sun's view is probably the excepted wisdom. But some leading Java guys are rethinking this, like Alan Griffiths, Bruce Eckle, and Rod Johnson.

Code written using checked exceptions tends to exhibit a couple of problems: catch clauses are often stubbed out for expediency, leading to "swallowed" exceptions. Also, all calling code ends up bloating with handling for errors that the caller may not want/need to handle.

Why not let callers catch what they want, otherwise let the error propogate up the chain? Rod defines the following rule of thumb from when to use a checked exception:

Should all callers handle this problem? Is the exception essentially a second return value for the method?

For Example,

Spending limit exceeded in a processInvoice() method

I seems to me right now that this is the way to go. Basically, throw checked if the caller can and should do something about it, otherwise throw unchecked.

Wednesday, August 10, 2005

Looking at Spring

I have found that I can no longer resist the Spring Framework. Having been beguiled by its popularity and intrigued by its principals, I have decided to spend some time checking it out. The following chronicles my findings.

First, I am really interested in some of the underlying design goals, for which I turn to Chapter 4 of Rob's book, at the ServerSide. Spring aside, this is just a great essay on OO design.

So far I am impressed. Dependency Injection is just too sensible, and makes TDD much more practical.

To Be Continued...

Monday, August 08, 2005

Shameless Promotion 3: John in a Nutshell

I am a software development expert who can contribute directly to successful application development, and also make broader contributions to an organization's success:

  • I know how to develop software with maximum value for any timeframe and budget.
  • I am a versatile professional who can fulfill many roles... roles often requiring several resources.
  • I am a highly productive contributor, I can get solutions done quickly.
I have top notch software development skills--coding expertise in Java and experience in C, Perl, VB, and Ruby; architecture, analysis, and design skills; and competence with a host of acronyms (UML, J2EE, SOAP, SQL, TDD, Ajax etc.)

Hands-on development is my foundation, but I have also worked hard to hone strong business skills: I have an MBA, several years of line and technical project management experience, and polished communication skills. I have led technical teams of 10 people, departments of around 20, and have countless hours interacting with Clients at all levels.

Encompassing both my technical and business skill sets is an overarching expertise in software development. This expertise is what enables me to deliver maximum value for any timeframe and budget. My unique combination of skills allows me to add strategic thinking and decision-making on top of a concrete, in-depth understanding of technology. This combination is also what enables me to fulfill so many roles; from developer to architect to resource manager and more.

My Resume and generic Cover Letter describe my skills in much more detail.

In terms of full-time positions, my mix of skills probably best matches a Principal Engineer, Architect, or Lead role with a small software company or consultancy. I am also very open to freelance work, where I can deliver on projects of all sizes. On top of software design and development, I can fulfill many of the crucial needs of a successful project:
Planning, staffing, defining team structure and roles, scoping, defining development process and tools, prototyping, and architecture.

As a consultant, I must always keep an eye out for the next gig. I'd love to discuss potential opportunities, whether in the planning stage or thereafter, Lead, freelancer, or other key role. If you are interested in someone like me, drop me a line.

- John Troxel

Denver, Colorado

jtroxel@yahoo.com

Shameless Promotion 2: John's Resume

John D. Troxel
Wheat Ridge, CO  ||  303.667.3280  ||   johntrox@gmail.com  ||  codecraftblog.com
Objectives
Opportunities to help companies outperform their competition with pragmatic software solutions.
To leverage my unique software engineering expertise and deliver effective solutions.
To provide the leadership in analysis, architecture, design, and engineering necessary to successfully launch and scale software products.
Skills Summary
  • BS Computer Science, MBA / MIS with over 20 years of software development experience, specializing in Web-based applications
  • Programming: Java, Javascript, Groovy, Ruby, C, Perl, JSP, Visual Basic, Python, Rails, Grails, AJAX, Spring, Maven, MySql, Oracle, MongoDB, Memcached, JBoss, Tomcat, Node.js
  • Software engineering methodologies, processes, and tools: UML, Requirements Analysis and Management, Agile methods, Unified Process (RUP). Object design (OOAD), system and software architecture, Open Source, SCEA, SCJP, Rational Certified Consultant RUP/OOAD
  • Technical line and project management, organization design, team mentoring
Professional Experience

Freelance Software Developer and Architect -- August 2012 - Present

codecraft solutions LLC, Denver

  • Execute custom design and development, Ruby, Groovy, Java, Javascript, and .Net
  • Conduct software refactoring and system architecture improvements enabling better scale.
  • Design and build mobile and single page apps using AngularJ, Ionic, and other JavaScript libraries.
  • Grails framework customization, data import processing, ecommerce web UI
  • Worked with clients including haughtcodeworks.com, The Trade Desk, and Deem.com

Senior Software Engineer -- September 2015 - June 2016

Reach150 Social, Los Altos
  • Primary architect and developer for new hybrid mobile application
  • Built platform and features using AngularJS, Ionic, Java, and Node.js tools
  • Enhanced service API using Java, RESTEasy, and Spring tools

Partner & Senior Developer -- April 2015 - September 2015

Forefront Labs, Denver/Lincoln
  • Partner and Sr. Consultant, developing custom applications
  • Specialized in Rails, mobile, and customer engagement

    Software Consultant -- July 2013 - March 2015

    Flickr/Yahoo, San Francisco
    • Refactored core Java middleware components for increased stability and maintainability
    • Revamped entire caching infrastructure: implemented Twitter twemproxy as a key platform component and integrated across hundreds of PHP and Java hosts
    • Enhanced the continuous delivery process spanning several technologies including Python, Perl, and PHP

    Principal Software Engineer -- March 2011 – July 2012

    Rearden Commerce, Foster City, California
    • Key architect and developer for content integration tools using Spring Batch, Camel, and custom tools.
    • Lead developer for a custom content curation system in Grails.

    Senior Software Engineer -- January 2008 – March 2011

    • Senior contributor to common Ajax and UI components.
    • Developed Endeca faceted search applications and data-processing tools.
    • Enhanced in-house MVC framework using Javascript and Java.
    • Contributed to design and development of new UI framework using Spring MVC.

    Freelance Software Developer & Architect -- June 2006 – December 2008

    • Lead all development efforts for BuyBak.com--an eCommerce startup providing reverse logistics capabilities--using Java, Struts, Spring, iBatis, Grails, as well as Ruby and MySQL.
    • Developed the system architecture and design (UML domain model, site map, etc.) for start-up healthcare service.
    • Developed Ruby on Rails, Javascript, and Java code to create a digital video system inside a Web-based, Ajax-style email system (Zimbra).

    Sr. Software Engineer -- March 2005 – June 2006

    McKesson (System Engineering Services), Denver, Colorado
    Java software design and development for mission critical applications.
    • Development key internal application using Java, Tomcat, XSLT, and AJAX
    • Development of all Web Service interfaces to the core system using JbossWS
    • Development of core components using JMX on JBoss

    Sr. Java Developer; Sr. Systems Analyst -- March 2004 – March 2005

    Veteran’s Administration (Express Management Solutions), Denver, Colorado
    Major contributor to critical systems development for the Health care Administration Center.
    • Leading establishment of System Analysis discipline and spearheading analysis of major initiative
    • Key team contributor for software architecture and programming for Oracle 9i and STRUTS

    Developer; Product Manager -- June 2002 – March 2004

    Grizella Corporation, Lakewood, Colorado
    Developer of Web-based products for a Transportation software company.
    • Architecture and programming for service-oriented system using Tomcat/Java Servlets/JSP
    • Developed an e-commerce ordering application with a credit card gateway interface
    • Created Web application to effectively utilize resources for a major Trucking association
    • Created a Web UI framework (MVC) for rapid development of Web-based services
    Technical Consultant -- February 2001 – May 2002
    Experio Solutions, Denver, Colorado
    Manager of technical project teams.
    • Project Manager for a critical process re-engineering of the IT department of a major utility
    • Developed components and workflows for a business service model using SeeBeyond
    • Contributed to J2EE and Enterprise Application Integration interest groups
    • Attended TIBCO training and maintained a Web-based InConcert demo
    Operations Director; Process Improvement Lead -- June 1998 – January 2001
    iXL, Denver, Colorado
    Various Management roles for Denver office of iXL.
    • Managed departments of up to 18 reports: Technical Services, Quality Services, Requirements Management
    • Successfully implemented improved Requirements Management and Change Request Management processes as Chair of Denver office best practices taskforce
    • Defined the corporate methodology framework utilizing RUP principles as key member of Corporate Methodology Team
    • Provided guidance to teams on program and project best practices
    Technical Director; Technical Lead -- October 1998 – June 2000
    iXL, Denver, Colorado
    Leader of technical development group for a top Internet-based business solutions company.
    • Managed technical teams of up to 10 developers, from requirements through deployment, for Budget Rent-a-Car, National Processing Corporation, and American Water Works Association
    • Lead Architect and Developer for ServletExec/NES/Oracle and IIS/SQL Server/ASP projects
    • Created and managed Technical Requirements and Architecture documents using Use-case specifications and realizations, sequence diagrams, and Deployment diagrams
    • Technical Project Management and primary technical interface with high-level Client management and vendor partners
    Director, Engineering Services -- August 1996 – June 1998
    iXL (Green Room Productions), Sausalito, California
    Leader of Web application development for a successful Web development company.
    • Established and managed the Engineering Services team, that grew to 17 employees
    • Internet application projects for travel clients including Sheraton Hotels, Walt Disney World, Travelocity, Mountain Travel Sobek, and Abercrombie and Kent
    • Developed interactive Web applications using Perl, Server-Side JavaScript (SSJS), Oracle, ASP, and MS SQL Server
    • Led development of Web-based Workflow system, including project, assignment, and hours tracking
    Systems Engineer (Part Time) -- May 1995 – March 1996
    Visual Movement Corporation, Denver, Colorado
    Internship with a software development team specializing in the transportation industry.
    • Technology selection and market research, implementation of installation utility in Visual Basic
    Associate Engineer -- June 1991 – August 1994
    Cooper & Chyan Technology, Inc., Cupertino, California
    Integral member of software engineering team for a start-up CAD software company.
    • Directed the design and content of a successful new GUI for an advanced CAD system
    • Maintained and enhanced a run-time graphics library using C, Motif, and X-Windows. This library was used to build the GUI listed above
    Education
    MBA / MIS. University of Denver (Daniels College of Business) June 1996
    · GPA: 3.51 / 4.00
    · Member of Information Technology Association and charter member of Toastmasters
    B.S. Computer Science. Colorado State University May 1991
    · Active member of Sigma Alpha Epsilon Fraternity. Vice President, Alumni Chairman
    Certifications
    · Sun Certified Enterprise Architect for J2EE, November 2003
    · Sun Certified Java Programmer, December 2001
    · Rational Certified Consultant in RUP and OOAD, March 2002

    Shameless Promotion 1: John's "Cover Letter"

    I am a professional software engineer and manager, and my expertise in software development can improve the success of software projects. I have over 11 years experience in software development as a leader and a key contributor in several roles.

    I am a leader who can code, and a developer who can manage people and projects. I believe I have a truly unique breadth of skills that make me an indispensable asset to software development projects:

    • Technical lead, architect, and developer on dozens of projects, including large engagements for clients like Sheraton Hotels, Travelocity, Budget Rent-A-Car, and the Veteran's Administration
    • Sun Certified Architect for J2EE
    • Programming experience in Java (4 years), C (3), VB/ASP (3), and Perl (2)
    • Sun Certified Java Programmer
    • Effective, hands-on skills as a software engineer, architect, and business/systems analyst
    • Several years of experience as an engineering line manager and as a technical project manager
    • Rational Certified Consultant in RUP and OOAD
    • MBA and a Bachelor's in Computer Science

    Please let me know if you would like a current resume, or to discuss how I can help you to succeed. Sincerely,

    John Troxel

    303.667.3280

    jtroxel@yahoo.com

    Thursday, July 28, 2005

    Unit Testing Thoughts

    In no particular order and with absolutely no structure, some thoughts on unit testing:

    • In order to properly unit test, your design must properly seperate concerns. This means that true business logic should be decoupled from specific APIs, conventions, and protocols... and these from eachother. For example, you shouldn't have the following mixed into business logic: SQL statements, JDBC calls, J2EE API objects, etc.
    • There is a spectrum from "pure" unit testing to complete integration testing, something like:
    1. (Pure) Unit Tests: Have no dependencies and no side effects: test constructors, accessors, comparisons, algorithms. Generally this consists of a single client, the test class, and a single class under test. Developed by developers for developers.
    2. Partial Integration / Integration Boundary Tests? Tests integration between layers, components, or technologies. Where possible, tests should focus on a single boundary, e.g. data access code <-> Database, SOAP Client code <-> SOAP Service, etc. Code that has dependencies on other APIs should use mock objects or some sort of debug-dummy mode. For the debug mode strategy, the property could be "injected" by the runtime invironment with a settor or a special constructor. These tests are also by developers for developers.
    3. Full Integration / System Tests? These test a path through the system that provides verification of some subset of requirements. These tests can be employed by developers, using tools like HTTPUnit. They can also be maintained by testers or properly trained business experts, using functional test automation tools.

    Many automated tests, including some unit tests, have side effects on the data that can mess up other tests. For example, tests may rely on a pre-condition state of the database to succeed, and manual testing can be maddening if the data is changing underneath you. Either all tests must mutate data completely independent of any other test or user, or the database must be restored to a consistent state before testing (which still might mess up other testers). Some strategies for managing this situation include:

    • Complete database restore, in an isolated database or schema. E.g. SQL DDL scripts, dbUnit scripts, or programmatically. If the developer's database is a different technology or version from production, this introduces the challenge of maintaining a restore capability for two technologies, as well as potential bugs caused by differences in the production database. To test for problems caused by a different technology in production, the team could use a shared database instance specifically for periodic execution of all unit tests. You could also have multiple levels of restore, e.g. a bare bones one for unit testing, one that adds reference data, and one that puts some example data in for manual testing. I like the idea of using Hibernate (or something similar) to abstract the db technology, using HSQL (or similar) locally, and providing utility methods to add in the required data.
    • Transactions / rollback? This implies that data access code must have mechanisms for using injected transactions, managed by the test code, and/or skipping commits in test mode. Add setAutoCommit, commit, rollback to DAO API?
    • Have each test clean up it's data. This requires that 1) all data created can be identified or tracked by the test, and 2) that the database allows the proper permissions to delete data.

    To Be Continued...

    Tuesday, July 26, 2005

    Qualifying the "Simplest Thing" rule

    In XP, and Agile methods, decisions are often made with the criteria of "the simplest thing that could possibly work." I think this applies not only to code construction and detailed design decisions, but to Architecture as well. Strict use of this rule will almost always result in the most prudent approach, but I do think there are a couple of caveats:
    1. The decision should still be reversible, so that you don't paint yourself into a corner for future changes in the requirements.
    2. The simplicity should be weighed carefully against the flexibility and the cost of changing later. If the simplest solution costs 20% less now, but will likely cost 30% more over time, then it may not be the best choice. You have to decide how likely likely is.

    I would stress that even with these caveats, one should still be very careful breaking the rule. If you don't have a strong case for a very real risk of ir-reversibility problems or future costs, you should just stick with the simplest solution.

    Friday, July 08, 2005

    JBoss CMP versus Hibernate

    UPDATE 07/26/05
    I stuck with Hibernate. Very simply put, they both have many of the same benefits--declarative programming, transactions, etc. But EJB introduces a whole layer of overhead realted to remote access. Unless you are doing a true N-tier, highly distributed application, I don't think that overhead is warranted.
    =======

    I am starting to look at a persistence technologies for an application I am working on in JBoss 4.0.2. I am currently looking at the (built in) Hibernate in JBoss versus CMP. SO far I am just kicking the tires, gathering info. If you come across this, please feel free to comment.

    Harshad Oak has a posting on the topic with comments.

    Right now, I can't see any reason why not to use Hibernate: I can use pojos, but still get transactions. I don't see the benefit of creating EJBs for every entity we need to persist.

    Thursday, May 05, 2005

    UML: Labels versus Stereotypes for Associations and Dependencies

    I think I am clear on what to use where for Associations: The label is very specific, identifying the association or relationship between the two specific nodes. A stereotype doesn't normally make sense for associations, since it identifies a kind of association. Examples I have seem is <<include>> for use cases, and identification of the protocol for component associations.

    For Dependencies: A label often does not make sense, since the relationship is always "depends on." A stereotype further defines the nature of the dependency.

    Good UML Links

    I really like Scott Ambler's stuff at: http://www.agilemodeling.com/style/

    This looks like a solid overview: http://www.vico.org/UML_FAQ_jGuru.pdf

    Looks interesting: http://www-inf.int-evry.fr/COURS/UML/semantics/

    And of course: http://www.uml.org/#UML2.0

    Hmmm: http://www.holub.com/goodies/uml/

    Wednesday, May 04, 2005

    Thoughts on Requirements Terminology

    It occurred to me a while back that there are two distinct categories of requirements: Those that are deemed necessary and can be categorically verified, and those that are more lofty and more difficult to test.

    I suggest that the first set are called Imperative Requirements, or simply requirements. These are binary in nature, either they make it into the system or they don't--a test case can be written that will pass or fail. Use cases and functional requirements fall into this category, as well as performance, reliability, security, and perhaps other non-functional areas as well.

    The second category, which I'll call Non-Imperative Requirements (or maybe just Qualities), are different. They can not be tested or verified in any straight forward way, but rather are qualities to shoot for. Scalability, maintainability, useability, and ease-of-development, for example, fall into this category. These Qualities are better expressed as goals with relative importance. Those less verifiable, these need not be completely useless. Qualities can be expressed with relative importance weights, and still traced with a correlation matrix.

    In future posts, I plan on fleshing out my idea of a requirements model, especially regarding how requirements should be systematically addressed in architecture.

    Thursday, April 21, 2005

    If you ever get a java.lang.NoClassDefFoundError at runtime, and you are certain the class identified is in your classpath, take a look at the inheritence hierarchy. The java.lang.ClassLoader will identify the child, even if it is a parent who is missing. At least that is what happened to me.

    Friday, March 25, 2005

    JBoss EJB Security

    In addition to the well-documented steps for securing EJBs, configuring in JBoss has some potential issues. Setting up an authentication policy requires editing some JBoss-specific files:

    conf/login-config.xml:
    <application-policy name="policy-name">
    <authentication>
    <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="optional">
    <module-option name="unauthenticatedIdentity">anonymous</module-option>
    </login-module>
    </authentication>
    </application-policy>


    META-INF/jboss.xml:
    <jboss>
    <security-domain>java:/jaas/policy-name</security-domain>
    ...

    If you set up a policy like this, you apparently must establish a method-permission in ejb-jar.xml for every method (or *) of every bean. Misnaming a method, or trying to do a partial wildcard (get*, can't do that), gives an error:

    Insufficient method permissions, principal=user, ejbName=Bean, method=method, interface=SERVICE_ENDPOINT, requiredRoles=[], principalRoles=[user-role1, user-role2]