Reflections: RMH Homebase

I had a really great time working with the RMH homebase. It gave me a chance to work in some both familiar and unfamiliar territory. Over the course of the semester I have been working on another project in Drupal. Drupal, is written in PHP like the RMH homebase, and requires a SQL database to be set up for testing. With Drupal I learned how to use LAMP in linux. By the time I needed to use it in the RMH homebase, I was ready. Now there were some new unfamiliar experiences that I enjoyed tackling.

  • SimpleTest- It seemed many of my classmates, as well as myself, have not seen nor used SimpleTest before for unit testing in PHP/SQL. Thanks to advice in my classmates’ blogs I was able to set it up and get it to run for my LAMP server.
  • Refactoring– Many classes at the college go over errors and syntax in code, and they go over documentation and style, but they never teach us how to adapt. When I sat down to look at the RMH homebase code, I got a chance to try and familiarize myself with another programmer’s code. Not just that, I had to refactor it. Refactoring on such a large scale was difficult at first, but the netbeans IDE has a neat feature that allows you to search all the files within a project for certain terms. Also simply trying to understand an unfamiliar complex system quickly was a challenge. By reading the comments thoroughly, and exposing myself to as much code as possible, I was able to really familiarize myself with the key aspects of the code.
  • Considering all angles– Lastly, complex systems, like RMH homebase, taught me that you must look at every aspect of a system, every detail, every inch, and every bit to fully understand the problem and address all possible issues. For example, the login manager completed its task correctly, but it did not complete it with good security. Finishing a task does not mean the task is complete.

These experiences helped to make me a better programmer and software engineer in more ways than one. I am glad to have had the opportunity to work on the homebase and look forward to taking these lessons into my future career.

RMH: The Final Countdown

This week we had to do 8.1 in our open source software book. This will be our last exercise in RMH. For this exercise we need to do three parts relating to the login system.

a. Suggest a more secure definition of default password assignment in RMH Homebase (currently the default password is the same as the login).

A great way to make a secure login is to take certain elements of a person to define the defualt password, such as a mixture of their id, name, and birthdate.\

b. When a person forgets their person, suggest a way it can be changed without needing to contact a house manager.

The easiest way for a person to recover their password is to provide secure information only that person will know, such as full name and birth date.

c. Revise login_form.php and implement your changes to the login. Be sure to test the revision and ensure it works in all cases.

I decided to mix the id, with the user’s last name. For example the password for id: 276, name:davidson would be davidson276. Then, to recover the password the user must type in their last name and their id number. Since the two are conceptually similar, they required less testing. All the tests from my SimpleTest passed.

 

This exercise was a great way to wrap up RMH for the semester. I will talk more about my over all experiences in my next post.

RMH homebase UPGRADED!

This week we finally got to upgrade our RMH homebase code to 2.0. This version includes some extra documentation, organization, functionality, and database tables. The following exercises refine this functionality and focus on SQL implementation.

 

7.1 Find examples of where the following criteria are broken in the dbDates.

 

>Every entry in the table has exactly one value of the appropriate type.

68 $shifts=$d->get_shifts();

69 foreach ($shifts as $key => $value) {

70 insert_dbShifts($d->get_shift($key));

 

$shifts is stored into value when it contains several different values and data types. This problem adds to the complexity of updating the values in the table, since you do not always know what types are being put into the table and in what order.

 

>No attribute in the table is redundant with the primary key.

 

58 $query=”INSERT INTO dbDates VALUES

59 (\””.$d->get_id().”\”,\””.

60 get_shifts_text($d).”\”,\””.$d->get_chef_notes().”\”,\””.$d->get_mgr_notes().”\”)”;

 

These values are all subsets of the primary key $shift. This can make it much more complex to search. If the primary key was only id, the search would be much easier.

 

7.2 Develop the functions get_shift_month, get_shift_day, get_shift_year, get_shift_start, and get_shift_end.

 

For this exercise I will only show the get_shift_month method, in order to prevent redundancy in this post:

 

function get_shift_month($id)

$shiftMonth = explode("-",$id);

return $shiftMonth[0];

 

This getter extracts the month from an array within the shift. Shifts follow the format MM-DD-YY-start-end. By creating an array separated at each dash, we can extract every value in an array created using explode() and return it to the parent function.

 

7.3 Design, implement, and test the calendar month view from the back of the book. This feature would allow the user to view all the shifts for an entire month. This feature requires us to add in a new module known as dbMonths. The simplest design I could use is code reuse. By using the code in dbWeeks and replacing the weeks with months. Below is the implementation of months:

 

include_once(‘Month.php’);

include_once(‘dbinfo.php’);

include_once(‘dbDates.php’);

 

/**

* Drops the dbMonths table if it exists, and creates a new one

* Table fields:

* [0] id: mm-dd-yy

* [1] dates: array of RMHDate ids

* [2] status: “unpublished”, “published” or “archived”

* [3] name: name of the month

* [4] end: timestamp of the end of the month

*/

function setup_dbMonths() {

connect();

mysql_query(“DROP TABLE IF EXISTS dbMonths”);

$result=mysql_query(“CREATE TABLE dbMonths (id CHAR(8) NOT NULL, dates TEXT,

status TEXT, name TEXT, end INT, PRIMARY KEY (id))”);

if(!$result)

echo mysql_error();

mysql_close();

}

 

/**

* Inserts a month into the db

* @param $m the month to insert

*/

function insert_dbMonths($m) {

if (! $m instanceof Month) {

die (“Invalid argument for dbMonths->add_week function call”);

}

connect();

$query = “SELECT * FROM dbMonths WHERE id =\””.$m->get_id().”\””;

$result = mysql_query ($query);

if(mysql_num_rows($result)!=0) {

delete_dbMonths($m);

connect();

}

$query=”INSERT INTO dbMonths VALUES

(\””.$m->get_id().”\”,”.get_dates_text($m->get_dates()).”,\””.

$m->get_status().”\”,\””.

$m->get_name().”\”,\””.

$m->get_end().”\”)”;

$result=mysql_query($query);

mysql_close();

if (!$result) {

echo (“unable to insert into dbMonths: “.$m->get_id(). mysql_error());

return false;

}

else foreach($m->get_dates() as $i)

insert_dbDates($i);

return true;

}

 

/**

* Deletes a week from the db

* @param $m the week to delete

*/

function delete_dbMonths($m) {

if (! $m instanceof Month)

die (“Invalid argument for delete_dbMonths function call”);

connect();

$query=”DELETE FROM dbMonths WHERE id=\””.$m->get_id().”\””;

$result=mysql_query($query);

mysql_close();

if (!$result) {

echo (“unable to delete from dbMonths: “.$m->get_id(). mysql_error());

return false;

}

else foreach ($m->get_dates() as $i)

delete_dbDates($i);

return true;

}

 

/**

* Updates a week in the db by deleting it and re-inserting it

* @param $m the week to update

*/

function update_dbMonths($m) {

if (! $m instanceof Month)

die (“Invalid argument for dbMonths->replace_week function call”);

if (delete_dbMonths($m))

return insert_dbMonths($m);

else return false;

}

 

/**

* Selects a week from the database

* @param $id week id

* @return mysql entry corresponding to id

*/

function select_dbMonths($id) {

if(strlen($id)!=8) {

die (“Invalid month id.”);

}

else {

$timestamp = mktime(0,0,0,substr($id,0,2),substr($id,3,2),substr($id,6,2));

$dow = date(“N”,$timestamp);

$id=date(“m-d-y”,mktime(0, 0, 0, substr($id,0,2), substr($id,3,2)-$dow+1, substr($id,6,2)));

}

connect();

$query = “SELECT * FROM dbMonths WHERE id =\””.$id.”\””;

$result = mysql_query ($query);

if (!$result) {

echo ‘Could not run query: ‘ . mysql_error();

$result_row = false;

}

else

$result_row=mysql_fetch_row($result);

mysql_close();

return $result_row;

}

 

/**

* retrieves a Month from the database

* @param $id = id of the week to retrieve

* @return the desired week, or null

*/

function get_dbMonths($id) {

$result_row=select_dbMonths($id);

if($result_row) {

$dates=$result_row[1];

$dates=explode(“*”,$dates);

$d=array();

foreach($dates as $i){

$d[]=select_dbDates($i);

}

$m=new Month($d, $result_row[2], $result_row[3], $result_row[4], $result_row[5]);

}

return $m;

}

 

/**

* the full contents of dbMonths, used by addMonth to list all scheduld weeks

* @return mysql result array of weeks

*/

function get_all_dbMonths() {

connect();

$query=”SELECT * FROM dbMonths”;

$result=mysql_query($query);

mysql_close();

return $result;

}

 

/**

* generates a string of date ids

* @param $dates array of dates for a week

* @return string of date ids, * delimited

*/

function get_dates_text($dates){

$d=”\””.$dates[0]->get_id();

for($i=1;$i<7;++$i) {

$d=$d.”*”.$dates[$i]->get_id();

}

return $d.”\””;

}

 

?>

 

After creating the module, I made the new module testdbMonths to help make assertions on the values of the database. The new code produced the correct results from the database and no bugs were overtly present.

 

These exercises were a great chance to try out SQL and PHP on open source software. I look forward to the final leg of the RHM source code exercises in chapter 8!

24th Annual Scientific Research Poster Session

This semester our team will be contributing our work on Drupal to the 24th Annual Scientific Research Poster Session. The session is an opportunity for students at College of Charleston to display long term research projects that they have worked on throughout their undergraduate career.  Below is an abstract I wrote descibing our work and detailing our main goal of the project. This abstract is also being submitted for the poster session. (details here)

Abstract:

Applications of Open Source Software in Computer Science Education
Matthias Burrell, Stephen Davidson, Jennifer Green, James Rajabi, and Tatiana Taylor, Department of Computer Science

Open source software has a wide variety of popular uses within culture today, but education is not one of them. Most schools rely on capstones or smaller projects to teach software engineering techniques and experiences. The purpose of this project is to demonstrate how working on software of a significantly large scale, namely open source projects, provides a better learning experience for the student. This project also exposes the student to a greater variety of challenges and obstacles, much more than standard computer science education methods. Our open source experience came from the use of the website management software, Drupal. By experiencing the open source process first hand, our team was able to collectively show the advantages of open source style eduation in the software engineering fields. The experience we had provided substantial evidence for the benefits of open source. Through community involvement within Drupal, submitting bug fixes and patches, and discussing Drupal issues within the community’s IIRC channels, we accrued a brevity of experience that will be invaluable for all of our team members into the future. We saw this project as proof that open source software is an effective method for teaching student software engineers the core principles of engineering.

POSSCON!!!!

This week was the Palmetto Open Source Software Conference (POSSCON). This event was a blast and I would like to take a chance to recount some of my favorite events, speakers, and moments. I arrived at around eight on Thursday. After checking in and receiving my official POSSCON badge, I headed with my classmates to the main lounge called Richland. Here we got to see a speech by keynote speaker, Scott McNealy, founder of Sun Microsystems. The speech was pretty informative. He went over the history of open source software and outlined many of the issues facing open source software including leadership and organization. Personally though, I disagreed with him that open source had slowed down or that it needs a big industry leader with lots of capital to thrive. As another speaker asserted when I asked about what McNealy had said, John “maddog” Hall said that he has seen no slow down in open source, and that the very design of open source prevents it from needing a large leader. The accessibility of open source software keeps it running strong.

Mentioning John, I got to visit several other speakers presentations. John’s was the most interesting. He was doing a BOF during the lunch period in the Richland hall. I already mentioned what I had asked. Others asked about copyright and patent. Richland felt that patents were necessary but needed a great deal of reform. Likewise, to him copyrights have way too long of a shelf life, and they also need reforms to adapt to the new age of technology. He also was quite humurous. He made sure to point out that Linus is pronounced ‘Lee-nus’ (an earlier speaker had said it could pronounced either way). Jokes like this made me a huge fan. He was both an interesting and informative speaker.

I also visited a kickstarter presentation by a young entrepreneur. Ian Daniher has started his own hardware business at age 20. The software used on his hardware is completely open source and versitle. This presentation was really great because of how young Ian is. Hearing of such a young man developing such an awesome idea is quite inspirational. Having toyed with self-development, hearing the business side of the hardware was not only interesting but different from any of the other speakers. He even demonstrated his device for us. The device known as CEE displayed electronic and heat signature in wave length form to the monitor. Ian showed the program’s versatility and ease of change. It was impressive to say the least.

The third speaker I took a look at was from the Department of homeland security. Security and open software seem like a paradoxical combination, but Douglas Maughan Ph. D proved this paradox wrong. He had a power point set up describing how open source software is used in the daily operation of homeland security. In fact he claimed that all the research done on open source software has proven it is actually more secure than its proprietary brothers. This fact alone was shocking. I was really glad I came to see his thoughts.

After seeing these stellar speakers, I and my classmates collected our belongings and made the short trip back to Charleston. The conference was a blast and I hope to go back next year. I took a significant amount away from the conference. I see the prevalence of open source much better now, and I appreciate what it has to offer more. I will take these lessons with me into whatever field I enter into or in whatever project I will undertake.

POSSCON is upon us!

POSScon is up and coming! This Thursday I will be heading to the Palmetto Open Source Software conference in Columbia, SC. This conference is a great opportunity to meet other employees within the business of open source software, and to hear their opinions on the effects of open source software in the industry. Here are a few presenters I look forward to seeing, as well as a few questions to ask while I am there.

10:30-11:15am
Michael Weinberg

Mr. Weinberg will be discussing the intellectual property ramifications of 3D printing. This talk interests me because 3D printing seems like a viable next step in the chain of newer printing technology. I would like to see his thoughts on the practical matter of developing 3D printers instead of the theoretical and laboratory side of development.

Question: What kind of restrictions could be placed on 3D printers to protect copyright and are they even reasonable/practical solutions?

12:15-13:30pm
Kevin Whinnery

Kevin will be talking about mobile development and the open source community surrounding it. Mobile development is a field I am interested in getting into, and I would find it advantageous to hear his thoughts in this field in regards to open source.

Question: How much harder is it to organize an open source community for mobile development rather than stationary? Are there any noticeable differences within the communities?

14:30-15:15pm
Jesse Andrews

One of the keynote speakers for this day will be Jesse Andrews. He will be discussing the effect of the cloud upon open source software. Many of the cloud developers have very rigid APIs that hinder development and innovation. Jesse wants to talk about ways to handle this issue. As another newer technology, I look forward to hearing about the cloud’s effect on open source software. It should be an intriguing presentation.

Question: How do the APIs of cloud development on mobile compare to the ones imposed on stationary development? Is one worse than the other?

Exercises in developing domain classes: Part I

Today’s post is a continuation of exercises in RMH Homebase. For these exercises we will be taking a class and further refining it. In this case we will be looking at the person class.

6.1 Define a new pair of functions to set and retrieve the value of variables $employer, $contact_person, and $contact_phone.

Added in variables:

class Person {

private $employer;

private $contact_person;

private $contact_phone;

Added in getters and setters:

function get_employer(){

return $this->employer;

}

function get_contact_person(){

return $this->contact_person;

}

function get_contact_phone(){

return $this->contact_phone;

}

function set_employer($e){

$this->employer=$e;

}

function set_contact_person($cpe){

$this->contact_person=$cpe;

}

function set_contact_phone($cph){

$this->contact_phone=$cph;

}

6.2 Add four new parameters and corresponding assignments to the constructor for the Person class, so that the status, employer, contact person, and contact person’s phone are properly intitialized. Use the following prototype for your new constructor:

function __construct($f, $l, $a, $c, $s, $z, $p1, $p2, $e, $t, $status, $employer, $contact, $contact_phone, …)

Here is the new initializer:

function __construct($f, $l, $a, $c, $s, $z, $p1, $p2, $e, $t, $status, $employer, $contact, $contact_phone, …){

$this->status = $status;

$this->employer = $employer;

$this->contact_person = $contact;

$this->contact_phone = $contact_phone;

6.3 Modify set_status function to check the the $value passed is valid. Describe unit testing implications of your design decision.

function set_status($st){

if (strcmp($st, “active”)==0 || strcmp($st, “inactive”)==0)

$this->status = $st;

else

$this->status = “error: bad input”;

}

This basic design allows for an simple set of test cases. {“active”, “inactive”, “test”}

The first two should change the status and the last should change the status to error. The other test cases needed are longer strings, blank strings, and numeral strings.

6.4 Refactor the person class by removing all the mutators that are not called from anywhere in the code base.

After removing a few mutators I rebuilt the RMH Homebase and tested to make sure the program was working. There were no visible signs of bugs after playing around with it for a hour.

Back on Track!

After a nice spring break, and a good recharge it is time to get back on track. Our main project Drupal is buzzing and busy as always and took no rest, so I took a chance to review some of the bugs from our time line and see if anything has changed. Sure enough, one of the documentation bugs, Bug 1444650, was fixed by the community. They went ahead and tidied up the documentation. Then, Bug 1431512  was reclassified as a non-Drupal related issue and cannot be patched within Drupal itself.

A few lessons are learned from this experience. For one, I learned to be more assertive in tackling bugs. I should go ahead and be more forthright in assigning bugs to myself to prevent other users from patching before me. Also I must be more proactive in addressing bugs so that they are not fixed before I have a chance to look at them. Basically it is all a matter of time management. Bug fixing like all software engineering must be a well-timed and organized process. Without this focus in mind efficiency is sacrificed in both the project and project community.

Thankfully there was one more bug left of my three that had not been looked at yet. So for this post we will focus on this one. Bug 1438990 details a language error that occurs within Drupal. Essentially when a node contains page translations, if the translations are a subset of the entire sites languages then instead of using the default language for the page, the node will use the first language within the array subset. The bug reporter provides some good screen shots to demonstrate the problem.

Notice the array for the node; the language default is set to english:

https://i0.wp.com/drupal.org/files/screenshot11.png

Now notice that the language is not English but Bulgarian:

https://i0.wp.com/drupal.org/files/screenshot10_0.png

In my next post I will provide bug injection details and possible fixes (if time permits). Also I will be reviewing other possible bugs to add to my new revised list. Until then, keep on programming!

Challenges of the Software Age

This week, we got a chance to delve into some open software news sources. The task was to take two articles from opensource.com and post our personal response and reflect upon the articles argument or thesis. For my first article, I chose one about Louis C.K., the comedian. I am a lover of comedy, and Louis C.K. is one of my favorites. To be honest, I was little surprised to see an article about him even covered in a software magazine, but once I read the article I fully understood.

The article states its premise outright, “The answer to stabilizing content and price is letting artists retain greater control of their work.” This claim is not unheard of and is a sound premise. It is based off of Louis C.K. providing a download of his stand up special for five dollars a pop. This model was used instead of the production model to prove that ease of access will generate revenue, and that the current system of production is antiquated. Using this method, he spent approximately 250,000 dollars. Surprisingly, he generated 1,000,000 dollars in revenue. The author of the article is arguing that this electronic method provided better user-developer relations, and allowed Louis to make better quality comedy because he had control over the entire production.

This argument needs to be heard many times over, and not just in comedy. Software can benefit from this method of thinking as well. Over and over we hear of software losses due to theft through pirating software. However, as the author of the article is saying, the issue can be solved simply through ease of access and a reasonable pricing model. Another great example of this thought is in mobile application development. The rise of easy to afford, easy to install, and mobile apps demonstrates this key principle: price and production affect piracy. The current structure of the software world promotes attacking individuals for sharing files, and punishing paying users with inconvenient protection measures. In the end, removing this methodology helps customer relations by making the paying user feel less punished for choosing the right way.

Also mentioned in the article is price. Price for software can reach upwards of millions of dollars. How much of this cost is purely administrative? How much comes from unnecessary costs such as advertising and publishing? When you go to the store and look at the sixty dollar game, I can tell you a significant chunk of that price is going straight to the publisher, not the developer. By removing these middle men in the modern internet era, we can reduce the cost of software to a point where it is almost non-existent (open source anyone?). We can create better software by fostering a more direct relationship between the end user and the developer. We can create better software for a better price by being in greater control of our development process. This point is what I construed from the article. Developers must always be agile in the field of fast-paced technology. So why not start adapting now?

The second article I chose was called “A cure of the common troll”. By troll, they are referring to patent trolling. With the rising boom in software comes new technology and innovations. These new technologies can all be patented in order to protect the developer’s copyright. Some companies will arise and have risen, whose sole purpose is to collect patents and then sue infringers. This is the art of the patent troll. The results of this trolling are adverse. For one, patent trolling restricts innovation by preventing smaller companies from developing without being sued out of existence. Another notable reason is that many of these patents have been bought, sold, and traded. These patents are not the true inventors but people who buy or acquire these patents from the inventors for profit. By choosing to do so, they are going against the whole concept of a patent to begin with: to protect the inventor. Lastly, many of the patents are dealt with in an archaic manner. A common analogy is that it is like patenting the door knob or the wheel. These are basic universal components that just cannot be patented because they are so basic and necessary to software development.

The article suggests a way to deal with these trolls of the modern age:

“First, create a compulsory licensing mechanism for patents whose owners are not making competitive use of the technology in those patents. Patent owners should be required to declare the areas or products that incorporate the patented technology. All other non-practiced areas should be subject to a compulsory license fee. (A non-practiced “area” would be a market or technology sector or activity in which the patent owner is not using or licensing the invention rights, though the owner may be using the patent in other “areas.”) Licensing rates for patents could be set by patent classification or sub-classification based on industry average licensing rates for each such technology. Again, this would only apply to applications where the patent is not being practiced or voluntarily licensed by the patent owner.
Given the vast number of patents issued, an accused party should have a reasonable, set time after receiving notice of a patent within which to pay for the license going forward. Compulsory licenses are authorized by the treaties we have entered into, and we have significant experience with compulsory licensing of copyrighted works from which to develop an analogous patent mechanism. Uniform rates could be set.
Second, cap past damages for trolls at $1 million per patent and eliminate the possibility of obtaining injunctive relief for infringement of patents that are not in use, or are not used commercially, by the patent owner.
Third, a mandatory fee shifting provision should be put in place where the plaintiff is required to pay the defendant’s reasonable defense fees if the plaintiff does not obtain a better recovery than what was offered by the defendant. (Presently, there is such a cost shifting mechanism in place; however, the relevant costs typically are a tiny fraction of the legal fees in a case.)
Fourth, for U.S. domestic defendants, require that suits be brought in the venue where the defendant’s primary place of business is located.
Fifth, if a party wants more than limited discovery from the opposing side, particularly for electronically stored information (ESI), the requesting party should pay the cost of production. For large technology companies, ESI production alone can cost into the seven figures.”

I am a big supporter of all these concepts. I would also add to the list, that patents cannot be bought or sold, only inherited or renounced (made open to all). By doing so, patent companies would be insolvent and inviable. Each of the other suggestions from the author are great ideas and should be considered in updating our current system of patent application and distribution.

These two articles discussed some hot button issues in not just open source development, but also in all forms of software development. I particularly enjoyed this assignment and found the articles to be both informative and interesting. I look forward to reading more!

Exercises in Ronald McDonald House source code

To follow up the unit tests from earlier this week. We have been assigned two more exercises from our software development book. The questions are as follows:

5.7.a) Locate the module in RMH Homebase that displays a shift’s “notes” field for editing.

     b)Locate instances of ugly code within the module,

The calendarFam.php displays a shifts notes for editing. Ugly code within this module is similar to the code in calendar.php such as

if ($edit==true && !($days[6]->get_year()<$year || ($days[6]->get_year()==$year && $days[6]->get_day_of_year()<$day) ) && $_SESSION[‘access_level’]>=2)
echo “<p align=\”center\”><input type=\”submit\” value=\”Save changes to all notes\” name=\”submit\”>”;

 

c) Define a new function called predate(a,b) that performs the same computation and returns true or false if a predates b, respectively. Insert that function as a new feature of the shift class.

predate($a,$b)

return($a <= $b)

d) Replace each instance of ugly code with new function.

if ($edit==true && predate($days[6]->get_year(), $year ) && predate($days[6]->get_day_of_year(), $day) && $_SESSION[‘access_level’]>=2)

e) Test refactoring.

All tests were successful. The refactoring worked perfectly. The bug shown in figure 5.15 was also fixed with this refactored code.