Wednesday, January 7, 2015

MyNotes: Organizing the Legacy Code

Now that everything is compiling again, I have a few choices on the next step. I can either rework the UI for the material design or I can start assessing the legacy code.

As you can tell from the title, I am starting with the code assessment.  Mostly, because I struggle with UI design and I can spend some time thinking about it and doing research while doing the code assessment.

The first step of the assessment is to organize the existing code.  This will force me to re-learn the architecture of the app and to make it easier to break down for test later on.   I already known that most of the code is going to completely overhauled, but I need to figure out what might be salvageable.

The legacy code base does not have any structure.  In some ways this make this easier since I don't have to remove any existing structure.

I am only grouping into rough categories right now.  I will refine and regroup the code as the refactoring process moves forward.  I am starting at the bottom grouping all of my database management code into a database package:

Next, I want to look for my data objects that are the accessors/modifiers for the database data.  In this case I only have one class, Note.  I am going to put this under a data package. Since I also consider the database to be data, I am going to move that package under data as well. This gives us this structure:

Since the bulk of the rest of the code is UI related classes, I am grouping these classes under a "presentation" folder.  Under that folder, I group the classes based on type.
I did a special grouping under components called "note_view".  This is because I tightly coupled the NoteView to the NoteEventListener.  I will have to make a note to decouple these classes later on.

That leaves two enums, NoteColors and ShareOptions, to deal with.  Since these are really just constants, I will put them under constants folder.

Now that we have the files grouped, the next step is to figure out what I want to keep, but that will be another entry.

Here is the commit for these changes :

Update: oops!  I missed an update to one file during the last commit.  The working commit is

No comments :

Post a Comment