Swen


refactoring final
December 6, 2007, 9:20 am
Filed under: Uncategorized

Types of refactoring

* Field encapsulation- Field encapsulation, also called data hiding, involves providing methods that can be used to read/write to/from the field rather than accessing the field directly. -This type of refactoring can be applied for Get and Set methods. 

*Advantages

  •  The internal storage format of the data is hidden. An expectation of the use of restricted character sets could allow data compression through recoding (e.g., of eight bit characters to a six bit code). An attempt to encode characters out of the range of the expected data could then be handled by casting an error in the put routine.
  • In general, the get and put methods may be produced in two versions – an efficient method that assumes that the caller is delivering appropriate data and that the data has been stored properly, and a debugging version that while slower, performs validity checks on data received and delivered. Such detection is useful when routines (calling or called) or internal storage formats are newly created or modified.
  • The location of the stored data within larger structures may be hidden and so enabling changes to be made to this storage without the necessity of changing the code that references the data. This also reduces the likelyhood of unexpected side effects from such changes. This is especially advantageous when the accessors are part of an operating system (OS), a case where the calling (application) code may not be available to the developers of the OS.

Bill’s team code Before encapsulationc

lass Appointment{      

private String apptDate;

}

code after encapsulation 

public String getAppDate()

{    Return appDate;}

Public void setAppDate(String a)

{   apptDate =a;

}

*Extract Class

- It is to turn the fragment into a method whose name explains the purpose of the method.- The new method is created containing the selected code, and the selected code in the existing member is replaced with a call to the new method. Turning a fragment of code into its own method gives you the ability to quickly and accurately reorganize code for better reuse and readability.

* Advantages

·      Encourages best coding practices by emphasizing discrete, reusable methods.

·  Encourages self-documenting code through good organization. When descriptive names are used, high-level methods can read more like a series of comments.

·  Encourages the creation of finer-grained methods to simplify overriding.

·  Reduces code duplication. 

Bill’s team code before Extract class

class Appointment

{

            private String apptDate;

            private String startTime, endTime;

            private String listOfUsers;

            private String purposeOfMeeting;

            private int meetingRoom;

}

Bill’s team code After Extract class

class Appointment

{

            private String listOfUsers;

            private String purposeOfMeeting;

}

class AppointmenttDetails {   (extracted class)  

private String apptDate;

private String startTime, endTime;

}

*Magic number -

Magic number is to create a constant, name it after the meaning, and replace the number with it. 

Bill’s team code before magic number

class Appointment

{

             private String apptDate;

            private String startTime, endTime;

            private String listOfUsers;

            private String purposeOfMeeting;

            private int meetingRoom;

}

public Appointment (String d, String startTime, String endTime, String userList, String purpose)

{

      apptDate = d;

      this.startTime = startTime;

        this.endTime = endTime;

         listOfUsers = userList;

     purposeOfMeeting = purpose;

    meetingRoom = 101;

            }

Bill’s team code After magic number

class Appointment

{           private String apptDate;

             private String startTime, endTime;

             private String listOfUsers;

            private String purposeOfMeeting;

             private static int meetingRoom = 101; (magic number)

}

public Appointment (String d, String startTime, String endTime, String userList, String purpose)

{

                        apptDate = d;

                        this.startTime = startTime;

                        this.endTime = endTime;

                        listOfUsers = userList;

                        purposeOfMeeting = purpose; }

 Bill’s team code before magic number

class Date {

            private int day, month, year;

public Date (int d, int m)

            {

                        day = d;

                        month = m;

                        year = 2007;

            }

 Bill’s team code After magic number

class Date

{

   private int day, month;

     private static int year = 2007; ( magic number) }

public Date (int d, int m)

{

            day = d;

            month = m;

}

 *Naming conversion

- change the names of the methods, variables and parameters to more meaningful name. This will make it easier for developers to understand the codes easily which are done by other developers.

 Bill’s team code before naming conversion

public Date (int d, int m, int y)

            { day = d; 

                 month = m;   

                  year = y;

}

public Date (int d, int m)

            {

                        day = d;   

                       month = m;

                        year = 2007;

            }

Bill’s team code after naming conversion

public Date (int day, int month, int year)

{

                        this.day = day;  

                      this.month = month;  

                        this.year = year;

            }

public Date (int day, int month)

            {

                        this.day = day;   

                         this.month = month;

            }

 Bill’s team code before naming conversion 

public Appointment (String d, String startTime, String endTime, String userList, String purpose, int room)

            {

                        apptDate = d;

                        this.startTime = startTime;

                        this.endTime = endTime;

                        listOfUsers = userList;

                        purposeOfMeeting = purpose;

                        meetingRoom = room;

            }

            public Appointment (String d, String startTime, String endTime, String userList,

                                                String purpose)

            {

                        apptDate = d;

                        this.startTime = startTime;

                        this.endTime = endTime;

                        listOfUsers = userList;

                        purposeOfMeeting = purpose;

                        meetingRoom = 101;

            }

 Bill’s team code after naming conversion 

public Appointment (String date, String startTime, String endTime, String userList, String purpose, int room)

            {

                        apptDate = date;

                        this.startTime = startTime;

                        this.endTime = endTime;

                        listOfUsers = userList;

                        purposeOfMeeting = purpose;

                        meetingRoom = room;

            }

            public Appointment (String date, String startTime, String endTime, String userList,

                                                String purpose)

            {

                        apptDate = date;

                        this.startTime = startTime;

                        this.endTime = endTime;

                        listOfUsers = userList;

                        purposeOfMeeting = purpose;

                        meetingRoom = 101;

            }



CVS commands
December 6, 2007, 8:53 am
Filed under: rika, yanglin

The various CVS commands include:

·  init ·  checkout ·  commit ·  add ·  remove ·  diff ·  edit ·  watchers ·  editors ·  import ·  export ·  history ·  log ·  annotate ·  tag ·  status ·  server ·  update ·  rdiff ·  rtag ·  release ·  login ·  logout 

The update Command
The update command synchronizes the changes in the repository source files with the files in the current working copy. This is useful when multiple end users are working on the same set of files. End users commit changes after you invoke checkout. This enables you to incorporate most recent revisions in the local working copy of the repository. For example, to update all the files in my_project except new.txt, the syntax is:
$ cvs update –I new.txt –P my_project

various options that you can use with the update command:

Option Description
-A Resets tags, dates, and keyword options.
-C Overwrites locally modified working files with original files from the repository. This is particularly useful if local files are corrupted.
-d Replicates the directory structure of the repository, if it is not already mirrored in the local working copy. This is useful if a directory has been created after you checkout.
-I Ignores the specified file.
-w Filters the specified file. You can use wildcard patterns to filter files.
-j Merges changes from the first specified revision to the second specified revision of the same file in the current working directory.

The commit Command The commit command saves the changes of the current working files into the repository. When you save a file in your working directory, it does not affect the repository. Source files in the repository are independent of your local files. With commit, you can save changes made to a local file into the repository, where the file is saved as a later revision of the original source file. For example, to save the original and changed files with revision numbers, such as 1.1 and 1.2, the syntax is:

$ cvs commit –m "New text file" new.txt


various options that you can use with the Commit command:

Options Description
-l Retrieves files from the current working directory.
-R Commits directories recursively.
-r Commits revision.
-F Retrieves log messages from files.

The diff Command The diff command shows the difference between two revisions of a file. If you invoke this command without any options, CVS shows the difference between the current local working file and the earlier revision stored in the repository. The current local working file need not be saved in the repository using the commit command. For example, to show a difference between the new.txt file, which is saved in the repository yesterday, and the local working copy of the same file, the syntax is:

$ cvs diff –D yesterday new.txt new.txt


various options that you can use with the diff command to display differences according to your requirement:
Options of the diff Command

Option Description
-lines Displays lines of context.
-a Treats files as text to compare files line-by-line.
-b Ignores white spaces.
-B Ignores changes, such as insertion and deletion of blank lines.
-binary Reads and writes data in binary format.
-brief Displays information whether the files differ.
-c Uses the content output format.
-d Changes the algorithm to find minor differences.
-expand-tabs Expands tabs to tableserve the alignment of tabs in the input files.
-H Handles large files with numerous scattered changes.
-I Ignores changes in the case.
-I Ignore changes, such as insertion or deletion of lines.
-L Uses label instead of the context format and unified format headers.
-s Displays a report when the two files are same.
-u Uses the unified output format.
-w Ignores white spaces when comparing files.
-y Uses the side-by-side output format.

http://www.gnulamp.com/cvsdiff.html



programming style(not completed)
December 4, 2007, 7:11 am
Filed under: findings, richard, syamir

Programming stylesProgramming style refers to a set of rules or guidelines used when writing the source code or a computer program. It is often claimed that following a particular programming style will help programmers quickly read and understand source code conforming to the style as well as helping to avoid introducing faults.Good style, being a subjective matter, is difficult to concretely categorize; however, there are several elements common to a large number of programming styles. Programming styles usually include the layout of the source code, including indentation; the use of white space around operators and keywords; the capitalization or otherwise of keywords and variable names; the style and spelling of user-defined identifiers, such as function, procedure and variable names; the use and style of comments. Code Appearance

Indenting – the indention of the codes in the sample code

 

Example :

public String getDate(){

                        return apptDate;

            }

 

            public String getStartTime()

            {

                        return startTime;

            }

                   Naming and logicAppropriate namings-         Appropriate choices for variable names are seen as the keystone for good style. Poorly-named variables make code harder to read and understand.Code conventions are important to programmers for a number of reasons:

  • 80% of the lifetime cost of a piece of software goes to maintenance.
  • Hardly any software is maintained for its whole life by the original author.
  • Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly.

Example:

public Date (int d, int m)

            {

                        day = d;

                        month = m;

                        year = 2007;

            }

 The variable d and m should be put as “day” and “month”.  

public Appointment (String d, String startTime, String endTime, String userList,

                                                String purpose, int room)

            {

                        apptDate = d;

                        this.startTime = startTime;

                        this.endTime = endTime;

                        listOfUsers = userList;

                        purposeOfMeeting = purpose;

                        meetingRoom = room;

            }

 The variable d should be have a name with more logic. E.g. “date”            

public int returnDay() {

                        return day;

            }

 

public int getMonth() {

                        return month;

            }

 

            public int returnYear()

            {

                        return year;

            }

The method name should be the same. In this case, returnYear() and returnDay() should be renamed to “getYear()”and “getDay()”                               Declaration of variable

The variables of the same data type should either be declared on the same line or be separated to one declaration of variable per line. This should be maintained and kept constant through out the entire source code.

  

Example:

private String apptDate;

            private String startTime, endTime;

            private String listOfUsers;

            private String purposeOfMeeting;

            private int meetingRoom;

 everything is listed in different rows except for the startTime and endTimeit should separate out each different variable to one line each. e.g. private String startTime;     private String endTime; 

Example:

private int day, month, year;

 Everything is listed in a line. The coder should actually maintain the same format of declaring variables through out the system. Therefore we should actually change it to,Private int day;Private int month;Private int year;                    Comments

Comments should be used to give overviews of code and provide additional information that is not readily available in the code itself. Comments should contain only information that is relevant to reading and understanding the program.

 

            public Appointment (String d, String startTime, String endTime, String userList,

                                                String purpose, int room)

            {

                        apptDate = d;

                        this.startTime = startTime;

                        this.endTime = endTime;

                        listOfUsers = userList;

                        purposeOfMeeting = purpose;

                        meetingRoom = room;

            }

 Comments can be added to the above method to help the user understands the codes betterAt the method head we can add this comment //creation of a new appointment



Refactoring
December 3, 2007, 3:02 am
Filed under: findings

Refactoring

hi guys, above attached files may be useful for u guys to know refactoring. =) 

(click on the word refactoring)



November 30, 2007, 12:12 pm
Filed under: Uncategorized

Teacher we have send the scenarios to your tp email. we couldnt upload the tables here…



CVS
November 29, 2007, 7:00 am
Filed under: Uncategorized

What is CVS?

CVS is a version control system. Using it, you can record the history of your source files.

For example, bugs sometimes creep in when software is modified, and you might not detect the bug until a long time after you make the modification. With CVS, you can easily retrieve old versions to see exactly which change caused the bug. This can sometimes be a big help.

You could of course save every version of every file you have ever created. This would however waste an enormous amount of disk space. CVS stores all the versions of a file in a single file in a clever way that only stores the differences between versions.

CVS also helps you if you are part of a group of people working on the same project. It is all too easy to overwrite each others’ changes unless you are extremely careful. Some editors, like GNU Emacs, try to make sure that two people never modify the same file at the same time. Unfortunately, if someone is using another editor, that safeguard will not work. CVS solves this problem by insulating the different developers from each other. Every developer works in his own directory, and CVS merges the work when each developer is done.

What is CVS not?

CVS can do a lot of things for you, but it does not try to be everything for everyone.

CVS is not a build system.

Though the structure of your repository and modules file interact with your build system (e.g. `Makefile's), they are essentially independent.

CVS does not dictate how you build anything. It merely stores files for retrieval in a tree structure you devise.

CVS does not dictate how to use disk space in the checked out working directories. If you write your `Makefile's or scripts in every directory so they have to know the relative positions of everything else, you wind up requiring the entire repository to be checked out.

If you modularize your work, and construct a build system that will share files (via links, mounts, VPATH in `Makefile's, etc.), you can arrange your disk usage however you like.

But you have to remember that any such system is a lot of work to construct and maintain. CVS does not address the issues involved.

Of course, you should place the tools created to support such a build system (scripts, `Makefile's, etc) under CVS.

Figuring out what files need to be rebuilt when something changes is, again, something to be handled outside the scope of CVS. One traditional approach is to use make for building, and use some automated tool for generating the dependencies which make uses.

See How your build system interacts with CVS, for more information on doing builds in conjunction with CVS.

CVS is not a substitute for management.

Your managers and project leaders are expected to talk to you frequently enough to make certain you are aware of schedules, merge points, branch names and release dates. If they don’t, CVS can’t help.

CVS is an instrument for making sources dance to your tune. But you are the piper and the composer. No instrument plays itself or writes its own music.

CVS is not a substitute for developer communication.

When faced with conflicts within a single file, most developers manage to resolve them without too much effort. But a more general definition of “conflict” includes problems too difficult to solve without communication between developers.

CVS cannot determine when simultaneous changes within a single file, or across a whole collection of files, will logically conflict with one another. Its concept of a conflict is purely textual, arising when two changes to the same base file are near enough to spook the merge (i.e. diff3) command.

CVS does not claim to help at all in figuring out non-textual or distributed conflicts in program logic.

For example: Say you change the arguments to function X defined in file `A'. At the same time, someone edits file `B', adding new calls to function X using the old arguments. You are outside the realm of CVS’s competence.

Acquire the habit of reading specs and talking to your peers.

CVS does not have change control

Change control refers to a number of things. First of all it can mean bug-tracking, that is being able to keep a database of reported bugs and the status of each one (is it fixed? in what release? has the bug submitter agreed that it is fixed?). For interfacing CVS to an external bug-tracking system, see the `rcsinfo' and `verifymsg' files (see section Reference manual for Administrative files).

Another aspect of change control is keeping track of the fact that changes to several files were in fact changed together as one logical change. If you check in several files in a single cvs commit operation, CVS then forgets that those files were checked in together, and the fact that they have the same log message is the only thing tying them together. Keeping a GNU style `ChangeLog' can help somewhat.

Another aspect of change control, in some systems, is the ability to keep track of the status of each change. Some changes have been written by a developer, others have been reviewed by a second developer, and so on. Generally, the way to do this with CVS is to generate a diff (using cvs diff or diff) and email it to someone who can then apply it using the patch utility. This is very flexible, but depends on mechanisms outside CVS to make sure nothing falls through the cracks.

CVS is not an automated testing program

It should be possible to enforce mandatory use of a test suite using the commitinfo file. I haven’t heard a lot about projects trying to do that or whether there are subtle gotchas, however.

CVS does not have a built-in process model

Some systems provide ways to ensure that changes or releases go through various steps, with various approvals as needed. Generally, one can accomplish this with CVS but it might be a little more work. In some cases you’ll want to use the `commitinfo', `loginfo', `rcsinfo', or `verifymsg' files, to require that certain steps be performed before cvs will allow a checkin. Also consider whether features such as branches and tags can be used to perform tasks such as doing work in a development tree and then merging certain changes over to a stable tree only once they have been proven.

http://durak.org/cvswebsites/doc/



pbl3
November 28, 2007, 1:18 pm
Filed under: findings, group

 -A code refactoring is any change to a computer program’s code which improves its readability or simplifies its structure without changing its results.

- Refactoring neither fixes bugs nor adds new functionality.

- Refactoring improves the understandability of the code.

- Changes its internal structure and design, and removes dead code, to make it easier for human maintenance in the future.

Examples of refactoring

-      Change a variable name into something more meaningful.

-      Complex refactoring is to turn the code within an if block into a subroutine.

-      More complex refactoring is to replace an if conditional with polymorphism. 

Types of refactoring

- Encapsulate Field

-Extract Method (to turn part of a larger method into a new method. By breaking down code in smaller pieces, it is more easily understandable. This is also applicable to functions)

 -Generalize Type

   -Pull Up

-Push Down

-Rename Method (changing the name of a method into a new one that better reveals its purpose).   

-Programming style refers to a set of rules or guidelines used when writing the source code for a computer program. It is often claimed that following a particular programming style will help programmers quickly read and understand source code conforming to the style as well as helping to avoid introducing faults.

Elements of good style

Code appearance

-Indenting

-Vertical alignment

-Spacing

-Naming ,logic and higher techniques

-Appropriate variable names

-Boolean values in decision structures

-Left-hand comparisons

-Looping and control structures

-Lists



pbl3 findings
November 26, 2007, 2:21 am
Filed under: findings, group

*Difference between testing and debugging?

First is testing

  - testing is a process of looking at a software system for the purpose of finding errors (no fixing only finding errors).

   -debugging is the process of locating the exact cause of the error and fixing it….

 Types of software testing methods

- Black box-send input data into the black box and watch the output data coming out (depends on the input test data)

-White box- looking inside the module in detail. Look at the specific code and test it out (test if else method, come up with test data test sequence of statements)

-Regression- Testing of modified software system to make sure that all the pre existing functions are still working. (Do it each time when there is a new feature is added)

 ·         Ways to start doing testing

-          Top down approach- start with the UI and go down until the lowest level

-          Bottom up approach- start testing with the components first and than go up until the full system is tested.

 

Integration testing – this is where many problems occurs.

-          Especially when there is huge team working on the module.

-          Main area to check during integration testing is interfaces between the different modules or units.

Plan at least 2 phases in the project.



PBL3
November 26, 2007, 1:36 am
Filed under: Uncategorized

What we know:

  • Pantheon Systems uses IBM testing system
  • Current appointment source code is not up to industry standards
  • we are to reccomend guildlines for good programming styles
  • we are to reccomend code refactoring to improve source code
  • the developers have difficulties in managing their software files
  • we are to explore the CVS

What we dont know:

  • how to do testing
  • IBM rational testing tools
  • industry standards of programming style
  • code refactoring
  • CVS
  • different testing methods/test data/test cases
  • manage sourcecode files

Deliverables

  • The presentation should be done as a group in the 1st session
  • Demonstration should be done individually per test case in the 2nd session.


Interface with other systems
November 22, 2007, 8:57 am
Filed under: Uncategorized

Interface with other systems

 Billing system

  • To be done later(WE NEED HELP)

 Employee’s Account system and Email system

  • Employee’s personal email is retrieved from the account system.
  • When the user forgets his password, a new password would be sent to his personal email which is found in the employee’s account system.
  • The information would be sent over in text format

 PDA system

  • Provides a download function for the user to be able to download and view his entire personal information management system.
  • This function only allows the user to read only and doesn’t allow the employees to create, edit or update and delete any of the data in the system.
  • The system shall allow the user to view his entire appointment schedule and details.
  • The system shall allow the user to view his entire contact list and details.
  • The system shall allow the user to view his entire to do task list and details.
  • The information would be sent in text format