Archive for the ‘Development’ Category

By Mike Hubbartt, © Copyright 2012, All Rights Reserved.

Title: The Object-Oriented Thought Process
Author: Matt Weisfeld
Edition: 1st (2000)
ISBN: 0-672-31853-9
Publisher: SAMS Publishing
Price: $29.99
Length: 226 pages (9 chapters, 2 appendices)

This book, according to the author, is ‘an introduction to fundamental O-O concepts’. It is not a book aimed at people already familiar with OO concepts, so bear in mind it is not intended for people that already understand OO development. I read the first edition of this book in 2000 and enjoyed it, but it sat on my bookshelf until last summer. I had a class in grad school at UST and the professor recommended this book before taking the class so I decided it was time to reread it. I read 3 chapters per day, so it only took 3 days to finish it, even though I took notes from each chapter. Like the 1st ed K&R, this book is not huge – 226 pages including the title page, table of contents, index, and acknowledgments – but it explains how procedural programmers can make the move to OO development. Let’s look at the book chapter-by-chapter.

Chapter 1 – Introduction to Object-Oriented Concepts

This chapter explains classes and objects and how they differ. Encapsulation, one fundamental advantage of OO programming, is covered nicely in this chapter, as is the introduction to the difference between a class interface and implementation, polymorphism, constructors, and overriding.

I liked the code samples included to demonstrate some of the concepts like overriding. I also liked the UML class diagram showing how class elements are displayed via UML – very easy to follow. I would have liked more code samples covers more concepts introduces in the chapter.

Chapter 2 – How to Think in Terms of Objects

This chapter teaches how to think in an OO manner. This chapter goes into the introduction of public interface and private implementation portions of a class. Very nice, clear, simple explanation. Not over or under covered – just enough to introduce the material that will be covered in more depth later in the book.

Chapter 3 – Advanced Object-Oriented Concepts

This chapter covers object creation and initialization, plus error handling. Very good explanation of constructors – what they must and must not have – and how there can (and often should) be more in some classes. Exception handling, which is a topic that could fill a book, is introduced here. There was a bit of source code showing how to use exception in Java code. I liked how the author covered static attributes, which can be used to allow multiple objects to share attributes.

Chapter 4 – The Anatomy of a Class

This chapter explains the differences between the implementation and interface of classes. This is the meat-and-potatoes section of the book. Where a class is broken down using Java to show the implementation and interface sections, as well as constructors. Very clear and my favorite chapter of the book.

Chapter 5 – Class Design Guidelines

This chapter explains that classes must interact and it covers the iterative nature of class design. This goes into design considerations, covering a safe constructor to initialize a class, serializing (deconstruct a object), persistence (maintaining the state of an object), and stubs (minimal implementations of an interface). More good Java code examples, although C++ concepts are also covered.

Chapter 6 – Designing with Objects: The Software Development Process

This chapter explains how to identify class responsibilities and class collaboration. This goes into the way to design an application, covering statements of work, requirements documents, and CRC cards. This was my least favorite chapter of the book – I liked the issues to take into consideration during the OO design process, but I’d rather have more OO concepts than requirements gathering information.

Chapter 7 – Mastering Inheritance and Composition

This chapter covers the differences between composition and inheritance. Very good coverage going into important means of code reuse: inheritance and composition. The author has nice UML diagrams to cover the concepts, and the text explanations are clear and accurate. I also liked how the book explains abstract classes and methods – very clear.

Chapter 8 – Frameworks and Reuse: Designing with Interfaces & Abstract Classes

This chapter covers frameworks and abstract classes vs Java Interfaces. Another good chapter, which covers APIs. I liked the code sample for an abstract class, and the author includes nice UML diagram that demonstrates a interface, inheritance and composition. A short chapter but good material and worth the time spent to read it.

Chapter 9 – Building Objects

This is where you learn how to use objects to build other objects. This goes into both types of composition: aggregations and associations. The author also goes into cardinality (a familiar concept to DB developers). I liked the material here but would gladly give up all of chapter 6 for more information in this chapter. Good, but I’d like more.

Conclusion

A very good book that is well illustrated, deep enough to explain the material without overwhelming someone new to OO development, and a good starting point for more advanced/in-depth books on OO development.I like how the author goes into UML enough, but not too deep to obfuscate the topic of OO development – the appendix is a good starter for people new to UML, but I wouldn’t recommend it as the source for programmers needing to gain more mastery of that topic.

Recommendation

I enjoyed reading it and will pass it along when I find someone that could benefit from it. The most current version of this book is the 3rd edition, which was published in September of 2008. I would recommend this book to undergrad computer science majors that learned to develop with any non-OO language, or for procedural programmers moving on to OO development. I would not recommend this book for an intro to UML

By Mike Hubbartt, © Copyright 2012, All Rights Reserved.

Spring is a nice Java framework that simplifies J2E tasks, and is in wide use in many real-world business development environments. If you don’t know it and want to do dynamic web development with Java, this is a good time to learn it.

You need a couple of things to do Spring development. A good IDE, Tomcat for local development, and a good database for dynamic content. I enjoy using Eclipse IDEs, so this Spring setup procedure covers Eclipse Indigo.

Spring Configuration

  1. Download and install Eclipse Indigo from http://www.eclipse.org.
  2. Download and install Tomcat 6 from http://tomcat.apache.org/.
  3. Download and install a relational DBMS like MySQL or SQL Anywhere for Developers.
  4. Download the Spring framework with dependencies (for this example, I downloaded Spring 2.5 RC2) from http://www.springsource.org/download and then unzip the file into a folder. I keep all of my Spring files a folder surprisingly called Spring – it holds the Spring framework files and any Spring-specific articles I find to be useful as references.
  5. Download the Spring plug-ins by
    1. Using Help – Install New Software.
    2. At the Install pop-up, select the Add button.
    3. At the Add Repository pop-up, use Spring for the name and http://dist.springframework.org/release/IDE as the location.
    4. Select Core/Spring IDE and Resources/Spring IDE, then press the Next button.
    5. Select the Next button.
    6. Select the ‘I accept…’ licensing option and then press the Finish button.
    7. Restart Eclipse when prompted after the plug-in is installed.
  6. In Eclipse, select File – New – Other, then select Dynamic Web Project, then press the Next button.
  7. Enter a Project Name, then press the Finish button.
  8. You have 2 options: create a WAR directory or use the existing WebContent folder. If you want to use the WebContent folder, skip to step 11, otherwise continue with this step. Create a war directory in the project – this is where non-Java source (.JSPs, XML, etc) are stored. In Eclipse, use File – New – Folder, and enter ‘war’ as the folder name, then press the Finish button.
  9. In the new war folder, create a WEB-INF folder using File – New – Folder just as you did in step 8.
  10. In the new WEB-INF folder, create a lib folder using File – New – Folder just as your in step 8.
  11. Time to configure the build path:
    1. Highlight the project name in the IDE, right mouse click (Mac users use Control-mouse click for the same list), then select build path/configure build path.
    2. At the Properties dialog box, select the Java Build Path option at the left of the dialog, then select the Source tab.
    3. Select the ‘Add Folder’ button, then select the ‘war’ folder – do not select the folders below war, then select the OK button.
  12. Now add 2 JARs to the project.
    IMPORTANT NOTE: Starting with Spring 3.1.0, there is no longer a Spring.jar file, so this process is best used with pre-3.1.0 Spring.

    1. Using Windows Explorer, locate the Spring.jar file, then drag and drop it onto the war/WEB-INF/lib folder in Eclipse.
    2. Using Windows Explorer, locate the commons-logging.jar file, then drag and drop it onto the war/WEB-INF/lib folder in Eclipse.
    3. With the project name highlighted, select File – Refresh from the Eclipse menu options.
  13. You are done – the project is ready to be used as a blank Spring project.

By Mike Hubbartt, © Copyright 2011, All Rights Reserved.

In the old days, developers used file system directories with customer naming conventions to organize their code and support files. This was a problem if the files were stored locally and the computer hard drive failed, and it made it difficult to keep code in sync when other developers had local versions of code that may have changes that impacted other areas of a program. Some companies used file servers to store source code, but again it could be difficult to keep source code synced if developers made local changes and forgot to update the main code on the file server.

The solution? Code repositories. Repositories are programs that store and organize source code, executable code, images, attachments, and libraries for client and server-based applications. Many companies also prefer to store project documentation like requirements, specifications, user guides, and project plans in their repositories. With repositories, materials are checked in and out as needed, and older historical versions of the materials are available for rollback (or comparison) in the event that code changes introduce a bug in the program.

Since many company applications are developed and maintained by more than one developer, repositories enable developers to access the entire application while working on their individual coding tasks. Each developer checks out part or all of the code, modifies existing or creates new code for their assigned tasks, tests their code, and then checks the code back into the repository. The changes are tracked, so it is easy to see who made what changes at any point of the project.

This post covers the procedure to setup a remote Git (a Distributed Version Control System) and a remote SVN (a Centralized Version Control System) repository. Please refer to our posts Configure Mac IDEs to Access a Remote Subversion Repository (June 15, 2011) and Configure Mac IDEs to Access a Remote Git Repository (June 24, 2011) for the steps to configure IDEs to access repositories like the two covered in this procedure.

ProjectLocker

I like ProjectLocker because Git is a popular repository in the business world and I’ve seen a number of companies move towards it the past year. ProjectLocker has one free plan where one to three people can share a SVN or Git repository, whereas Freepository also has a free plan but only one person can access the SVN repository – teams are required to pay a monthly fee to share the repository. ProjectLocker also offers five commercial plans where groups of 15 – 250 users can have SVN or Git repositories. I encourage students that want to learn about code repositories to check out this repository hosting site.

To get setup with a repository at ProjectLocker,  go to their website (http://www.projectlocker.com), register, setup a project, and then you are ready to configure your IDE so it can access your repository. Its pretty simple and straight-forward, so I won’t go into the setup at this time.

Something nice about ProjectLocker: refer friends and gain extra resources. For each friend that you recommend and they join ProjectLocker, you gain 50 MB of disk storage space. When 5 friends you recommend join ProjectLocker, you gain another user for your account.

Setup a ProjectLocker Account
  1. Go to the website (http://www.projectLocker.com), select the Account Type (the first one is free).
  2. Now enter an Account Name and Initial Project Name. Select the Initial Project Type (Git in this case), then enter your email address and a password to access your repository. Press the ‘Continue’ button to continue setup.
  3. Provide personal information as requested.
  4. You should receive a Account Created confirmation.
  5. Log into the ProjectLocker portal.
  6. The first time you log in, you will be prompted for a security question and a security answer. Enter both, then press the ‘Save Security Information’ button to continue.
  7. You now see the main portal screen.
  8. Stepping away from the Portal Page of ProjectLocker, you need a public key to communicate with Git via SSH. Open a Terminal Window and enter ‘ssh-keygen’. You are asked for a file name/location for the file (both a public and private key are generated).
  9. Back at the Portal Page, Select ‘Manage Public Keys’ underneath ‘User Links’ at the far left side of the page.
  10. Since no keys have been added, select ‘New Key’.
  11. Enter the Name, User name, and public key, then press the ‘Save Public Key’ button.
  12. A ‘Public Key <Name> Saved Successfully’ tells you the process was done correctly. Now select ‘User Home’ under ‘User Links’ at the far left side of the screen to return to your main portal page.

Codesion

Codesion, like ProjectLocker offers SVN and Git repositories for free and for a monthly charge.Check out their website for pricing information.

  1. To get started, go to the Codesion website and begin the sign up process.
  2. Enter your information. Your domain, login, and password entered at this time are used to log into your account, so keep track of them. Your email address is where you receive confirmation about the repository setup.
  3. Enter all the information with an asterisk beside the field label and select the ‘Create My Codesion Account’ button.
  4. Codesion emails confirmation the account is setup – check the email you specified in step 2 of this procedure.
  5. Login to your account. Enter your domain, login, and password, and then press the ‘Login’ button.
  6. Enter your industry information from the three drop down lists on the bottom of this page.
  7. Now enter a new project name and press the ‘Next’ button.
  8. Select Git or Subversion as the repository for your new project. For this example, select ‘Subversion’ and press the ‘Next’ button.
  9. Now select ‘Blank repository’ or ‘Best Practice’. For this example select ‘Best Practice’ and press the ‘Next’ button.
  10. You project is now setup. The screen now shows the project URL you need to access the repository from your IDE.
  11. Now that the project is created, you can view the website project tab in your browser.

Pretty simple process to setup a new remote SVN repository.

By Mike Hubbartt, © Copyright 2011, All Rights Reserved.

Code repositories are server-based applications to store common code. Our post Configure Mac IDEs to Access a Remote Subversion Repository (June 15, 2011) provides instructions on connecting an IDE to a remote SVN repository (Centralized Version Control System), while our post Configure Mac IDEs to Access a Remote Git Repository (June 24, 2011) provides instructions on connecting an IDE to a remote Git repository (Distributed Version Control System). This procedure covers configuring IDEs for remote repositories once they are setup or they are made available to you.

Configuring Git for Eclipse Galileo

  1. Launch Eclipse.
  2. Select ‘Help/Install New Software’ from the IDE menu.
  3. You are at the Install Screen. Enter (without the surrounding quotes) ‘EGit – http://download.eclipse.org/egit/updates-1.0&#8217; in the field beside ‘Work With:’, then press the ‘Add Site’ button.
  4. Expand the top section (Eclipse Git Team Provider) and select ‘Eclipse EGit’. Press the ‘Next’ button.
  5. Review the items to be installed and then press the ‘Next’ button.
  6. Select ‘I accept the terms of the license agreements’ (if you want to), then press the ‘Finish’ button to install the plug-in.
  7. After the plug-in is installed, restart Eclipse. At the top of the workbench, select the ‘Open Perspective’ button, then select ‘Git Repository Exploring’.
  8. This is the Eclipse Git perspective.

Configuring Git for Xcode 4

Configuring Git for Xcode is a bit more involved than it was to configure this IDE for Subversion. There are two extra processes involved: downloading and installing Git, and creating a symlink to the Git command line tool.

IMPORTANT NOTE. I heard that Git might already be installed as a part of Mac OSX but did not find it on my copy of OSX 10.6.7 (Snow Leopard). If anyone knows that it is pre-installed, please drop me a line to the directory location and I will update this procedure.

Lets get started, assuming we need to download and install Git.

  1. If Git is already installed, skip to step 6, otherwise proceed to step 2.
  2. Download Git. I went to this site and downloaded git-1.7.5.4-i386-leopard.dmg.
  3. Double click on the dmg file to install Git. My copy installed in /usr/local/git/bin.
  4. Open a Terminal, then enter cd .. two times to move to the root (/) directory, then enter cd /usr.
  5. Create the symlink to the Git command line tool: Enter the following command (assuming your copy of Git installs in the same directory as mine – see step 2 of this procedure):
     sudo ln -s /usr/local/git/bin/git /usr/bin/git
  6. Launch Xcode.
  7. Select ‘Window/Organizer’ to bring the Organizer to the screen, then select the Repositories section at the top of this screen.
  8. Select the ‘+’ at the bottom left of the Organizer screen, then select ‘Add New Repository’. At this point, select ‘Type’ and Git is now included in the list (along with Subversion) of supported repositories.  Enter a relevant name and the URL to the hosting site (ProjectLocker in this case, but others can be added for work and school sites as needed).

By Mike Hubbartt, © Copyright 2011, All Rights Reserved.

There are commercial repositories and open source repositories. The commercial repositories charge, usually based on the number of people accessing the repository. Open source repositories can be installed on internal company servers or there are companies that host open source repositories for no or little cost (also typically rated by the number of repository users). I’ve used Subversion (SVN), a centralized version control system, for company and class projects, so this article covers the the hosted version of SVN on Freepository with the Eclipse, Xcode 4, and Intellij IDEA 10 CE IDEs.

Freepository

Freepository has one free plan, where individuals can have a SVN repository for personal use at no cost. They also offer two commercial plans where groups can have SVN or Git repositories. I have found other sites that have good repositories with the same type of arrangements (free and billable setups), but I like how easy it is to setup and use SVN at Freepository and would encourage students that want to learn about code repositories to check them out.

To get setup with Freepository, go to their website (https://freepository.com/index.php), register, and you are ready to configure your IDE so it can access your repository. Its pretty simple and straight-forward, so I won’t go into the setup at this time. There are a lot of IDEs, so I’m focusing on Eclipse and Xcode for this article.

Configure Eclipse Galileo for SVN

These are the steps to configure Eclipse to use Freepository (or any other SVN repository):

  1. Launch Eclipse, then select ‘Check for Updates’. Some may be available since the last time your copy of the software was built, so get the updates before installing add-ons. Restart Eclipse if any updates were done.
  2. Select ‘Help/Install New Software’ from the Eclipse menu.
  3. At the Install screen, beside ‘Work With’, select ‘Galileo – http://download.eclipse.org/releases/galileo&#8217;.
  4. Scroll down to ‘Collaboration’ and expand that section.
  5. Select ‘Subversion SVN Team Provider (Incubation)’, then press the ‘Next’ button at the bottom of the Install screen.
  6. Verify this is the correct file and press the ‘Finish’ button at the bottom of the screen.
  7. After the add-in is installed, restart Eclipse.
  8. Now it is time to install the Subversion Connector. Select ‘SVNKit 1.3.0 Implementation (Optional), and restart Eclipse after the connector is installed.
  9. Now switch to the Eclipse ‘SVN Repository Exploring’ perspective.
  10. Select ‘New repository location’ at the top/left area of Eclipse.
  11. Enter the repository information (your company’s own or the one from the Freepository in the previous section of this document) in the field beside URL in ‘New Repository Location’ popup. You also need to enter your user name and password at this time to avoid being asked for it whenever you try to access Freepository. I also prefer to select ‘Save Password’ so it is not necessary to re-enter it each time I access the repository.
  12. Now select the ‘Finish’ button. After the repository is added, you can select it in the ‘SVN Repositories’ window (typically at the far left side of the Eclipse ‘SVN Repository Exploring perspective). Please note Eclipse supports multiple SVN repositories, and it is common to have multiple SVN sites for personal, work, and school projects.
  13. All in all SVN works well with Eclipse.

Configure Xcode 4 for SVN

Xcode 3 is shipped with most Macs and is available free to developers that join the Mac/iOS Developer Program, or for $4.99 from the Apple App store. Compared to Eclipse, Xcode 4 is very easy to setup for SVN.

  1. Launch Xcode 4.
  2. Select ‘Repositories’ at the top of the Xcode Organizer.
  3. Select the ‘+’ sign at the bottom left of the Xcode Organizer, then select ‘Add Repository’.
  4. Enter the name and location, then press the ‘Next’ button to finish setting up the repository.
  5. You can leave the Trunk, Branches, and Tags as is for Freepository, then press the ‘Add’ button to complete setup. Select ‘Repositories; at the top of the Xcode Organizer screen to see the new repository.

Not a lot to do to get yourself setup for using a code repository, which is something most new developers learn when starting their first job as a programmer.

Configure IntelliJ IDEA 10.5 CE for SVN

Probably the easiest of these three IDEs to configure to access a remote SVN repository. All you need to do is connect to the repository.

  1. Launch IDEA.
  2. Select ‘Version Control/Browse VCS Repository/Browse Subversion Repository’ from the IDE menu.
  3. To add a new SVN repository, select the ‘+’ beside ‘Repositories:’ at the top of this popup screen, or select the repository from the list in the popup to access an existing repository. To see the projects in each repository, expand the appropriate repository folder.

By Mike Hubbartt, Copyright 2011, All Rights Reserved.

This brief tutorial is meant to help people get started writing their first Ruby program using the Eclipse IDE.

Step 1: See if Ruby is already installed.

Ruby does ship with some operating systems, however it is available for multiple operating systems here.

  1. To verify it is installed on your Mac, launch Terminal and enter ‘irb’ to start interactive Ruby. If the prompt changes to ‘>>’, enter a simple Hello World program like ‘puts “Hello Ruby on Mac world!”’
  2. To verify it is installed on your Linux computer, open a shell and enter ‘irb’ and , enter a simple Hello World program like ‘puts “Hello Ruby on Linux!”’.
  3. If you have a Windows computer, you need to download and install Ruby, then follow the instructions to test Interactive Ruby on Windows here.

Step 2: Get setup with Eclipse

  1. Download and install Eclipse if you don’t already have it.
  2. Launch Eclipse, then locate and install the Ruby Development Tools plug-in using the Eclipse ‘Help/Install New Software’ menu option. At the Available Software dialog box:
    1. Select –All Available Sites– for the ‘Work with’ drop down list.
    2. Expand the Programming Languages section and select ‘Dynamic Languages Toolkit – Ruby Development Tools’.
    3. Press the Next button, review the options, then select the Finish button.
  3. Use the IDE ‘Eclipse/Preferences’ menu option to pull up the application preferences dialog, then select ‘Ruby’ on the far right of the dialog.
    1. Expand the options under ‘Ruby’ and select ‘Interpreters’. If none are displayed, select the ‘Search…’ button at the right side of the screen to locate any installed interpreters. Apple ships a ruby interpreter – in OSX 10.5.x I found them in /usr/bin/ruby.
  4. Now use the IDE ‘File/New/Ruby Project’ to create a new Ruby project. Name it to any convention you follow (type of project, class, etc.).
    NOTE: You want to use the Ruby Perspective when writing Ruby code, which is available using the IDE ‘Window/Open Perspective/Other’ option and selecting ‘Ruby from the list.
  5. Select ‘File/New/Ruby Class’ to create your first Ruby program. Name it hello, then enter this simple Hello World program to confirm you can create and run a Ruby program:

    class hello
    def hello
    puts “Hello Ruby World”
    end
    end
  6. Save and execute the file and verify you see the text string in the Eclipse console. Congratulations. You just created your first Ruby program using Eclipse.