Hiatus on Project while Reading Book

This week I made little to no progress on the modify dosage system. I have spent most my time on reading  the Head First Design Patten book. Seeing that the book is about 620 pages I was unable to truly read through all of the content, so I had to pick and choose certain sections to read and skim through the rest. My first impression of the Book was that I was intrigued by the outline of the book. The book does a great job keeping you interested by a variety of ways. Some of which include crossword puzzles, humor and plenty of interactive diagrams. The book also teaches in more of a conversational problem solving manner giving you the feel that you are actually working through problems with other programmers instead of dry technical explanation for the examples. The patterns covered in the text include the Strategy, Observer, Decorator, Singleton, Iterator, Composite, Factory, Facade, State, Proxy, Command and Template Method. An appendix provides a very quick rundown on a few more that didn’t make it into the main text. These patterns are introduced in a gently gradually growing manner that adds additional objects to extend the patterns as you gain the idea of and master array of patterns. I liked the way that the book made you think about and decide which pattern would most effectively solve the problem at hand. Throughout the book they introduce real-life problems that the author has you consider many possible solutions. He even has you consider solutions that aren’t the best idea. After the consideration of the solutions the author will even describe to you why the bad solutions are as such. The entire books examples are written in java so it fits in well with Worcester States courses seeing that the majority of the programming classes are java based. I feel that introducing design patterns in a freshmen course would be beneficial seeing that design patterns are used in every real world application. The book continuously stresses the idea of favoring composition over inheritance in most cases, as well as programming to an interface. The author tries to stress a “Has A” relationship is much better than an “IS A” relationship. The book uses a great example of this; the example states that not all bathrooms have bathtubs, so we probably don’t want to include a bathtub in a Bathroom class. I wish I would have had more time to actually be able to read the entire book, but with all of my other classes and final project going on I just didn’t have the time. I also want to try to finish the modify dosage system before this semester ends, so TR and I are going to try to find a decent amount of time to get together and work on it. We are still having trouble correctly data binding some of our textboxes and drug selection drop downs. A lot of the code comes from several levels of classes, so it is difficult finding exactly where implementation is needed. As I stated in my last post I was able to create a drug concept and add it to a current patient, so I will start to work on this project after this upcoming Monday.

From the blog mlopatka by matthewlopatka and used with permission of the author. All other rights reserved by the author.

Week 10 ( what we are doing in the class)

March /31/2014

At beginning of the  class, every group’s leader presented the group status. After that, the professor ask us to create the Junit test for the student class and the Degree Audit class,   which is belong to  a J Unit lab master project we got from the git hub on the website: github.com. First, fork the J Unit-lab Repository :

1. Go to the J Unit-lab repository at https://github.com/kwurst/junit-lab
2. Fork the J Unit-Lab repository to your account.
3. Add your instructor and partner(s) as collaborators

Second, download the J Unit lab Repository:

1. In Eclipse, choose File:Import
2. Choose Git:Projects from Git
3. Choose Clone URI
4. Paste the SSH clone URL from GitHub
5. Set the protocol to SSH

6. Select the master branch
7. Choose the directory you want to clone into.
8. Select Use the New Project Wizard
9. Choose Java:Java Project
10. Enter a project name.

After reading the code of J unit-lab code, then create the Student test class and the Degree Audit test class, then I write the test method for every method in  each class. making sure the tests are run correctly, I run to test every single method after I wrote the code for that method. If the test pass it result will display the green bar or the test fail the result will display the red bar.

 

From the blog herangoc » cs@worcester by emtrieu and used with permission of the author. All other rights reserved by the author.

Week 9 ( Group Workign Status)

This week we are working on the new ticket TRUNK -243 ( Clean up Unit Test). In two week ago, one of the guy in the group, he wrote the comment to ask the software developer what is the directory to work on this ticket but we still waiting for the answer.  When we changed some of the code  on a second ticket TRUNK-3009 on wiki page, we got a problem because a developer did not clear on what we had changed,  even we asked them already. That is why , we don’t want to go ahead before getting the answer from a developer. Currently, I’m looking a J-junit test on the google. I’m still looking for any project that relate to the unit test.

From the blog herangoc » cs@worcester by emtrieu and used with permission of the author. All other rights reserved by the author.

Trials

The majority of this week was spent switching from OpenMRS 2.0 and applying the earlier and more stable version of OpenMRS, version 1.9.7. I also decided to reinstall the large test database that was downloadable through OpenMRS. The reasoning behind this was that I was unable to create a drug regimen and then modify that regimen for a current patient. I thought that it might have something to do with the way I initially installed OpenMRS and or the test database. I wanted to see if I was getting the java.Lang errors because the data wasn’t getting parsed into OpenMRS correctly. So I began by uninstalling the latest version of OpenMRS and reinstalled the earlier and more stable version 1.9.7. Once I made the switch and ran mvn clean install and jetty:run, I reconnected to OpenMRS and remembered that I no longer had my large patient database, so I decided to move forward to create a patient instead of reinstalling the entire database. After I created the patient I once again attempted to add a new drug regimen to the patient and again just as before I was given two general errors when I would attempt to add a drug regimen. The first error stated that the start date for the drug regimen had to parse a year in a four digit format (which was happening). The second error was complaining that there was no existing drug ID for the drug name I was trying to assign to the patient. Growing in frustration over the fact that I have been unable to add a regimen so that TR and I can actually get to test our modify dosage system I decided to reload the large patient database one last time and see if that would make a difference. Once I reinstalled it I started MySQL I opened the tables just to make sure that my copy of data wasn’t corrupt. After I satisfied myself that the data was not corrupt I again restarted OpenMRS. Now armed with a full database I tried adding regimens to dozens of different patients with no avail. With this approach obviously not working I started to think that maybe my permissions were set wrong on my development account. So, I went into my Manage User page just to check and I found that my permissions were set correctly. Now totally frustrated I decided to take a break and rethink my current dilemma. Instead of trying to add a drug regimen to a patient I decided to create my own drug and concept and assign it to a patient under the Manage Drug Orders option in the Administration page. First I created a concept because I found out that you cannot create a drug without having a concept first. So with the creation of my concept I went ahead and created the drug Advil, yes Advil, surprisingly enough Advil was not in their database for an available drug. After the concept and drug were created I went into the Manage Drug Orders page in the Administration section and was able to select a patient and actually assign that patient to the new drug I just created. Although this method worked it is still not the correct way to assign someone to a drug regimen. Seeing that TR and I are running out of time to complete this ticket in class we are going to just have to accept that our system may not ever add regimens correctly, but at least now we are able to begin testing whether or not our implementation is functioning correctly. If it is not we will at least have time to re-work the code.

Till next time,

Matthew

From the blog mlopatka by matthewlopatka and used with permission of the author. All other rights reserved by the author.

Unit Test: @should annotations

Basically what I’ve been doing is introducing the “@should” javadoc annotation. Each api method will get one or more @should annotations that simply state a behavior of that method need testing, in other words, each @should annotations should be phrased. For instance:

  • @should not fail given null parameter
  • @should return empty list if no results

The example above would become unit test named (given the method was findPatient):

  • public void findPatient_shouldNotFailGivenNullParameter()
  • public void findPatient_shouldReturnEmptyListIfNoResults()

These are the step I followed to get started on this task:

  • Import the OpenMRS-core Repository from Eclipse
      • In Eclipse, choose File:Import
      • Choose Git: Projects from Git
      • Select Repository Source: URI
      • Browse the location of the local file on the PC (file: openmrs-core)
      • Select the master branch
      • Choose the directory you want to clone into
      • Select Use the New Project Wizard
      • Choose Java: Java Project
      • Enter a project name (To get all files imported, the given name has to be exactly the same as the local file name. In this case the project name should be: openmrs-core)
  •  Start searching all methods that do not have tests
      • In Git Bash, type command:  $grep –r ‘@should’ openmrs-core  (This command line will recurs into sub-directories to look for all “@should” instances)
      • Command:  $grep –r ‘@should’ openmrs-core > file.txt   (This line will save the output to a file text)
  • Browse ‘@should’ annotations in the packages  
      • The txt.file will output all packages that still have ‘@should’ annotations.
      • In Eclipse, look for such packages and start modifying them, so those methods become unit test names.
      • For example: /api/src/main/java/org/openmrs/somepackage/SomeObject.java:

In Eclipse: /api/src/main/java/org/openmrs/aop/AuthorizationAdvice.java:

From the blog Naty Zelaya » CS@Worcester by natyzelaya and used with permission of the author. All other rights reserved by the author.

General Update

So, turns out that whole compilation/posting of our completed ticket wasn’t as ‘complete’ as we’d thought. That is to say, rather than compile everything and post it to GitHub, we ended up trying to compile all our individual code first….repeatedly. It took a bit of playing around with, but we figured out that it could all be compiled and pushed up through the GitHub GUI. For whatever reason, whenever we tried it on the Bash, it just wouldn’t work properly.

After finally getting it sent up, we still hadn’t heard back from the admins about whether we’d properly fulfilled the requirements, so we’re not sure where to go with all of this. As a group, we pretty much decided to focus on the book reports that would be due soon, and just wait for confirmation. As I’ve still not heard from Dhimitris (who originally claimed the ticket), all I’ve been doing is reading more from my book.

Frankly, I was right. Reading glorified textbooks isn’t that fun. I prefer sci-fi/fantasy to non-fiction 😛

From the blog Kyle's Works » CS@Worcester by kyleprimmer and used with permission of the author. All other rights reserved by the author.

OpenMRS DB issues

I wrote a detailed blog on what I have done since my last entry and in an attempt to undo a paste I hit cmd+z and it deleted everything I wrote. In my anger and frustration I will not be redoing it in as much detail. Essentially what I have been working on was trying to get the correct configuration for the mySQL database. I initially installed mySQL with homebrew. I think this led to some configuration issues so what I did was uninstall the homebrew version of mySQL and re-installed it with the mySQL .dmg that is provided from the mySQL official page. Once this was done there were several steps to take to configure mySQL. I used the instructions provided here for the installation, and here for the post installation configuration. Finally I followed the instructions here to change the root password. Once mySQL was all set up I started tomcat and hit the openMRS site. This launched the initial configuration to the DB, I chose the simple setup with the demo data. Once this was complete I found that I did not seem to have any of the data. To solve this I followed the instructions here. Once the data was added I was able to search for a patient and find one. After that I was able to add a drug regiment which was what we needed to be able to test.

Once we added the drug to a patient we could see where the drugs that a patient is on are populated and the buttons that come along with them. This lead us to decide to redesign how our functionality was implemented. We added a button at the bottom that will have a box open where you can select a drug that a patient is on (a feature that we found doesn’t work as we thought), modify the dosage and how often they should take it. We want to move this box up so that it comes more inline with the buttons that are present with each drug.

This is how it currently looks:
You click the button next to the green arrow and the content in the green box comes up.

We want it to look more like this:

This is what we will be working on now.

From the blog A blog about things by TRStaake and used with permission of the author. All other rights reserved by the author.

Java Interfaces

This week I have decided to take the blog in a different direction.  Instead of blogging about the weeks’ progress and what’s to come, I am going to start focusing much more on being informative and helpful to readers who may have had similar troubles.  Today, I am going to be talking about interfaces in Java, and how I used them in developing my Rafter Maker app for Android.  Now, why would I want to use an interface?  Well, an interface will allow you to pass objects in your code generically.  For instance, I can create any number of objects which implement the Rafter interface and then pass them all throughout the code defined generically as Rafter.  This makes it possible to retrieve the same data from any type of rafter through a generic variable, while allowing the code in each rafter object to  be unique.  I created some examples to illustrate my point.



public interface Rafter{

getAngle();
getLength();
getName();

}

Above, is a simplified example of the Rafter interface in my app.  The original has more methods, but that’s the only difference.  



public class ShedRafter implements Rafter{

private double angle, length;

public ShedRafter(double rise, double run){
// calculate angle and length from rise and run
}

@Override
getAngle(){
return angle
}
@Override
getLength(){
return length
}
@Override
getName(){
return "Shed Rafter";
}

Above is a simplified example of a shed rafter class from my app. Notice it implements the Rafter interface and overrides each empty method declaration in the interface. Any class that implements an interface must override all the methods within that interface otherwise you will get an error that says something like “must implement the inherited abstract methods” meaning the abstract (undefined) methods in the interface.


public class GableRafter implements Rafter{

private double angle, length;

public GableRafter(string pitch, double span){

// calculate angle and length from pitch and span
<pre>
@Override
getAngle(){
return angle
}
@Override
getLength(){
return length
}
@Override
getName(){
return "Gable Rafter";
}
}

Above here is a simplified example of a gable rafter class from my app which differs from the shed rafter class, but notice that both classes implement the Rafter interface allowing the creation of a Rafter object that can be a ShedRafter or a GableRafter .


double span = 144, rise = 60, run = 144;
String pitch = "5/12"

Rafter rafter = new ShedRafter(rise, run);
rafter = new GableRafter(span, pitch)

The classes take different  arguments with different names and the algorithms for calculating a rafter from a rise and run versus a pitch and span are also different; though I don’t show them for the purpose of simplicity.  This approach allowed me to perform completely different calculations in each rafter object and on different variables, while still adhering to the interface definition by overriding getAngle(), getLength() and getName().  This way both classes were Rafters and Rafters are  generic.   While in contrast each individual rafter class implementing Rafter’s  is  unique.

This made it easy to create any rafter on the fly and pass it to my output class, which is responsible for displaying the angle length and name of  the rafter.  Now there is no need to check or know what type of rafter you have, because it does not matter, all the differences between rafters have been compartmentalized within the individual definitions.  For instance, the getName() method is easily modified to return the proper names for each rafter, and likewise I can easily change the way I calculate angle and length in the constructor.  The behavior of methods I might add to the interface later on will also be easily modified and will require minimal updating to the code overall.


double span = 144, rise = 60, run = 144;
String pitch = "5/12"

Rafter rafter = new ShedRafter(rise, run);

System.out.println("Print " + rafter.getName() + " Data\n");
System.out.println("The angle is = " + rafter.getAngle());
System.out.println("The length is = " + rafter.getLength() + "\n");

rafter = new GableRafter(span, pitch)

System.out.println("Print " + rafter.getName() + " Data\n");
System.out.println("The angle is = " + rafter.getAngle());
System.out.println("The length is = " + rafter.getLength() + "\n");

Above you can see it is easy now to define a single Rafter variable and use it to get the values from any rafter class which implements the Rafter interface.

Well, thats it for this blog.

Till next time.

From the blog jasonhintlian » cs-wsu by jasonhintlian and used with permission of the author. All other rights reserved by the author.

Unit Testing

As a group we continue working and trying to find more detailed information about the assigned ticket. Unfortunately, the lack of communication and responses from the developers is limiting the progress of our project.

Last week, we did the JUnit Lab in class, which was very helpful in understanding how unit testing works. I had to install GitHub in my laptop to be able to open git files in Eclipse. To start working on the Lab, I had to fork JUnit-Lab Repository to my account and then I cloned it from Eclipse.

After going through and finish the lab, I tried to follow the same steps with the OpenMRS-core Repository. I ran into problems, but after so many attempts I finally got to clone the repository by importing the project from a local source. 

From the blog Naty Zelaya » CS@Worcester by natyzelaya and used with permission of the author. All other rights reserved by the author.

A blog about things 2014-04-07 14:03:00

Since my last post Matt and I have accomplished a few things. One we finalized the layout of the modify dosage feature we are looking to add. What we did was mimic the layout of the section used to add a new drug regimen. When you click on the modify dosage button a box opens up in the current window that has an area to modify the a drug regimen. The box contains a drop down populated with all the current drugs that the patient is on. There is also a text box to modify the dosage. There are some drop downs to modify the frequencey of drug administration, There is a “start date” box that will pop up a calendar that you can use to select a date. We added a Submit button that should submit the data and a clear button that will clear all fields.

Since the layout is all set now all we need to do is test. This is where we are coming into some issues. We are not able to add drug regimens to a patient. This makes it impossible to see if our drop down will populate with all the medications that the patient is on. Since we can not add a drug regimen we can not modify one. We are currently working to find out what is the issue here. My guess is that it has to do with the DB that we are connecting to.

Another thing that we have done was create a build script that reduces the time to deployment. Initially, when we run a maven clean/install it takes about 8 minutes to build and deploy. This means that any changes we make and want to see will take at least 8 minutes. We cut this down to about 1 minute by running the maven install with the skip tests flag.

  • mvn install -Dmaven.test.skip=true

While this helps in development we realize that the unit tests are important and so once we have reached a state that we are happy with we run the build with the tests as normal.

From the blog A blog about things by TRStaake and used with permission of the author. All other rights reserved by the author.