Stephen Nimmo

31Jan/080

Houston Java Users Group January Meeting

Greetings. Our first HJUG meeting of 2008 was last night and it was a great success. We had a huge turnout (32) and heard great feedback from the participants. John Tyler presented an assessment of his work using Fit and gave a different prospective than what the HJUG is used to, choosing to discuss more of a business-wise side of testing, rather than a tutorial on the product. It was very informative and John did a great job straddling the business-IT fence and discussing integrated testing through the eyes of product owners and developers. It was great to hear an honest (and even negative at times) assessment about a product, rather than the normal "wow-this-is-the-greatest" presentations.

Special thanks to Coolhires for sponsoring the event.

I also picked up Kent Beck's book Implementation Patterns which I will be writing a review for. Started it this morning on the bus ride in to work, and so far it looks interesting. Not a run-of-the-mill patterns book, but rather an introspective on why we code the way we do. There are a few quotes in the introduction that will become subjects of posts very soon.

Here's some pics from the meeting. Our next meeting is February 27th on Grid Computing. See you there.

IMG_0671

IMG_0674

IMG_0672

Tagged as: No Comments
25Jan/080

California ISO – Market Redesign and Technology Upgrade

http://www.caiso.com/MRTU_Overview/caliso_frame_c.html

Overview of the current changes for CAISO.

I still find it hard to believe the absence of a forward energy market in California for the past 6 years.

Tagged as: , No Comments
25Jan/080

Dates and Indexing in Oracle

Indexing in Oracle for dates can be a bit tricky, especially if you do a lot of querying according to a date without a specific time element. The issue stems from the trunc() function. Any trunc function basically negates the value of an index on a date column in oracle.

Instead of doing something like:

select * from table where date = trunc(to_date('01/01/2008', 'mm/dd/yyyy')

which, if you have an index on date will basically remove the benefits, try using:

select * from table where date between trunc(to_date('01/01/2008', 'mm/dd/yyyy') and trunc(to_date('01/01/2008', 'mm/dd/yyyy') + .999

This allows you to have the power of the trunc without sacrificing the speed of your index.

Thanks to Eddie.

http://awads.net/wp/2005/11/29/oracle-sql-tip/ 

Tagged as: , No Comments
10Jan/080

Class and Method Signature Organization

Class organization, in particular method signature patterns, can provide many benefits to the developers. Primarily, we live in a day and age of the beautiful IDE with the glorious auto completion functionality. I think I hit ctrl+space more times a day than you can imagine. Utilizing patterned method signatures give the developer the opportunity to find all methods of a certain type quickly.

Let's look at some basic functionality encountered on a daily basis.

  • Finder methods - these are typically data retrieval methods designed to return a collection of objects to the caller. This is the most common type of method and has many different permutations.
  • Save Methods - Save methods are typically used to persist data or state to some data store. I typically write save methods so that they dynamically handle the logic regarding whether the data needs to be inserted or updated.
  • Delete Methods - You guessed it.
  • Run methods - Run some other process in the background. This usually involves a stored procedure, threading, etc.

Let's look at some method signature templates for these types.

Finder Methods

public Interface findInterface(Object var1, Object var2);

public Collection<Interface> findInterfaces(Object var1, Object var2);

You'll notice the return value of the method is a collection of interfaces and that interface name should be used in the findXXX method name. What does this do? Developer can locate all finder methods on an interface by typing "fin" and then auto completing. This also allows the developer to find a particular methods associated with the interface they are working with. Let's say we have an interface representing an energy deal. Here's what it would look like.

public Deal findDeal(long dealId);

public Collection<Deal> findDeals(String energyType);

public Collection<Deal> findDeals(String counterpartyType);

Ok, so this is a bit different from what you might have seen in other development environments. For example, some shops might go with a pattern of public Collection<Deal> findDealsByEnergyType(String energyType); and include a description of the parameters in the method signature. Where this breaks down is when you go work for an ACTUAL development shop that has a bit more complicated interface. Can you imagine writing a method called:

public Collection<Deal> findDealsByPriceCounterpartyIdFlowDateStartDateEndDatePipelineId(Double price, long counterpartyId, Date flowDate, Date startDate, Date endDate, long pipelineId);

This could easily be changed to:

public Collection<Deal> findDeals(Double price, long counterpartyId, Date flowDate, Date startDate, Date endDate, long pipelineId);

Why? The parameter descriptions are RIGHT THERE. Make the parameter names descriptive and kill two birds. Not too mention the benefits of camel casing get destroyed. I have even seen some shops put an "And" between each of the parameters. Talk about LONG methods. Also, order becomes an issue.

However, this is impossible if you decide to do things such as:

public Collection<Deal> findDeals(Double d1, long c1, Date date1, Date date2, Date date3, long p1);

The parameters MUST have descriptive names.

Exceptions can be had but follow the signature as close as possible. For example, let's say you wanted two methods for finding deals - one for the exact start date and end date and one for finding all deals between a date range. Here's how to do it.

public Collection<Deal> findDeals(Date startDate, Date endDate);

public Collection<Deal> findDeals(Date betweenStart, Date betweenEnd);

But what happens if you have a particular need to locate all deals that fall within the date range but don't necessarily have all of it's dates inclusive in that range? That's where you'll need to step out of the pattern and write something custom.

public Collection<Deal> findDealsNonInclusive(Date betweenStart, Date betweenEnd);

The secret to method signatures is to follow the pattern as closely as possible but as with everything else, there will be exceptions. Be smart about it and make sure to review the anomaly with the team to explain why you stepped out.

Save Methods

public Interface saveInterface(Interface var1);

Same method signature allows for quick auto completes. Always return the exact object, populated with any auto generated data such as auto increments.

Delete Methods

public void deleteInterface(Interface var1);

Same simple pattern. See how easy it gets?

Run Methods

public void runProcessName();

This signature type allows for encapsulation of the implementation details from the caller. For example, let's say you have a stored procedure summing the value of a day's deals. Calling that stored procedure using this signature:

public void runDealAggregator(Date flowDate);

This allows to to search for what you want to do in layman's term and doesn't require the developer to know (or care) what the name of the actual stored procedure is. On top of that, if you change implementation, to say, kick this job off on a separate server via a web service call, you don't have to rename it. You would if you method signature looked like:

public void callSPDEAL_AGGREGATOR_FOR_DATE(Date flowDate);

In conclusion, method signature are a great way for your team to self-organize it's code. There are also some additional ways to help with code organization such as method ordering (finds first, then saves, then deletes, then runs). The trick is to decide on a template, and follow it.

Other potential benefits include generic transactional capabilities. For example, you (normally) don't want to start and end transactions for simple finder methods but you would always want to on a save. Hibernate and aspects could be used to wild-card match on method signature, so any method with a save* signature has transactions required.

Good luck with your code and remember, if you don't periodically review code, this kind of thing won't be followed - I can guarantee it.

Tagged as: , No Comments
8Jan/080

Scrum Explained

Anyone looking for a website to guide your through the principles of Scrum and how to implement Scrum in your shop?

Check out Kelly Water's blog - All About Agile. How to Implement Scrum in Ten Easy Steps

I think step one should be expanded though. There are 3 very important things to happen prior to implementing Scrum. First, explaining it to the product owner and all stakeholders. Next, getting buy in. Third is creating and prioritizing the backlog.

One and three are easy. Getting buy in not to interrupt the team on the whim of a VP - almost impossible.

Tagged as: , No Comments
7Jan/080

Professional Development Opportunities in 2008

I ended 2007 with a flurry of activity. I participated in the Sun Certified Enterprise Architect Beta Exam for Java 1.5 during the final two months of the year and barely finished in time, mostly because of the compressed time requirement due to the beta status. I studied only two weeks, maybe 20 hours total. I found the test to be challenging and incorporated some different technologies and concepts. Although the test is brand new, it still feels like it was written 2 years ago. Passed Part One. Finished the project in 3 weeks. Took the essay exam the next week. Don't get the results until Feb 15th. I am assuming I passed.

During this time, I was also preparing for a company wide technical presentation on Spring 2.5. Knowing and understanding Spring is one thing, but trying to explain dependency injection and inversion of control to someone for the first time via a web conference is hard. I got some good feedback, especially from my colleagues up in the NYC office and I am looking forward to expanding the presentation soon.

So with all this activity at the end of the year, and after a refreshing Christmas break, I am ready to tackle some more opportunities. Here's my short list:

  1. ScrumMaster Certification. This one I actually started setting up last year. It's all set. I'll be attending the course, here in Houston, on February 13th and 14th, with Peter Borsella. I am stoked about this because we are having a company-wide technical conference 2 weeks later in Miami and I am hoping to be a part of the push for integration of Agile methodologies into consulting work, especially fixed-cost projects.
  2. Certified Associate of Project Management (CAPM), PMI - This is something I am targeting for Q2 of this year, after I return from my vacation in March. I am largely a technical kind-of-guy and I am wanting to round my experience more.

So after that, I am looking at Q3 and Q4 as a blank canvas as far as technology goes. What can I learn in six months? Should I go ahead and bite the Microsoft bullet, get cross trained in C# (which is basically Java, without the control) and become a player in the dark side? What about moving away from programming languages and moving toward Oracle and DBA-type knowledge?

Along the same lines, I am looking for more in-depth training and understanding of trading, hedging and other activities involving both financial and energy derivatives. I polished off the Nontechnical Guide to Trading Natural Gas which I enjoyed as it presented a majority of the hedging strategies for natural gas trading. I have a lot of experience in transportation services after having worked for Enron Transportation Services (Northern Natural Gas, Transwestern, and Florida Gas Transmission) as well as Spectra Energy, but have only been in natural gas (energy trading) for about six months, mostly on the risk side after an implementation of a risk product for a client in Indianapolis, in which I was the technical architect. For the next month, I am going to begin to research the free and company-sponsored avenues to becoming an expert in energy trading and will report when I make my decisions. If you have any suggestions regarding learning energy trading, please shoot me an email or leave a comment.

2Jan/081

Agile Estimation Videos

Agile Estimation, Mike Cohn

http://www.youtube.com/watch?v=fb9Rzyi8b90&feature=related

http://www.youtube.com/watch?v=jeT0pOVg0EI

Pretty good watch.

Tagged as: , , 1 Comment
2Jan/080

Hibernate Generic DAOs

http://www.hibernate.org/328.html

This has been the slickest implementation of a generic DAO interface yet. I have used this exact implementation, with some small tweeks, in several projects and continue to try and expand on it's capabilities. This implementation provides almost plug and play functionality for all generic CRUD DAO calls just by creating a domain object, a DAO interface and implementation class.

So what work actually needs to be done? Hibernate Mappings (but that can either be annotized or completed via an IDE plug in - specifically, the hibernate plugin for Eclipse), creation of the three classes and then writing any custom finder methods.

The pattern begins to get a little convoluted when you start trying to manage complex objects so you may have to adjust your strategy.

Tagged as: No Comments