CSC/ECE 517 Fall 2010/ch6 6c VP

From Expertiza_Wiki
Jump to navigation Jump to search

Namespaces is a set of names which are bound together to form unique identifier in order to resolve conflict with same names from different context. Namespaces give you control over the visibility of the properties and methods that you create in a program.

What is agile project methodology?

While computer software has become a driving force for the modern world, software development itself is not a perfect process. Today, software development has gained pace and needs to become more flexible. To meet the needs of today’s customers, a new software development methodology called Agile Software Development has come into existence. Agile methodologies is a completely different approach compared to the traditional software development methodologies. Agile means quick and active. Agile methodology is based on iterative development, where whole team collaborates to decide on requirements and solution to solve a particular problem. Agile project management is an application of these Agile software development ideas into project management.

How agile projects are different from projects

Agile methodology is totally different than traditional software development techniques. This is due to the fact that unlike traditional techniques, agile process works in iterations, each of which are of a short time frame and do not involve long term planning. Iteration period differs from team to team and all project participants view themselves as one team to achieve the goal. In agile process, the stages are also slightly different from that of the traditional processes like Waterfall. The 5 stages that are described in the agile development methodologies can be defined as follows

Envision: This is the phase where the team visualizes the requirements through a data sheet. This is analogous to use case list in UML.

Speculate: This phase is to provide a general direction of the project and begin the planning phase. Though it is similar to that of waterfall model, the plan is broken down into short iterations based on the features.

Explore: This phase acts as an execution phase in the lifecycle. The distribution of work, technical practices, team development are all done during this phase. This is different from the Implementation phase of the waterfall model as it focuses on the complete dynamics of the project.

Adapt: In this phase, all the corrections and changes that are to be made are applied to the project. This can be analogous to the testing phase in waterfall model. The major difference here is that the results of this phase are sent to the re-planning of the next iteration.

Close: The objective of this phase is incorporate the learning of this iteration or project into next iteration or passing it on to the next project team.

Purpose of estimations

Estimation and planning are critical steps of any software development project irrespective of its size. Planning plays a prominent role in deciding on the investments, availability of the resources and customer values. In any case, good estimation leads to good planning. Estimation of cost and schedule is the deciding factor when it comes to whether a particular feature has to be implemented in an iteration.

There are 3 types of planning namely: Release planning, Iteration planning and Daily planning.

Release planning - Both size and velocity estimations are helpful for release planning phase. The estimation of the capability of a team to deliver the product in the given time is called Velocity. This velocity combined with the total feature size, which is another estimate of project will help in deciding the release date.

Iteration planning - The major focus of this phase of planning is to decide on the features that are to be selected for the current iteration and which one’s are to be moved to the next iterations. This phase of planning helps the product owners to prioritize the features and redesign the scope of the project if required.

Daily planning - Traditional methods decide on scope and delivers all features together whereas agile projects deliver in units of features. These features are describe as user stories and user stories has business values for customers. This phase is mainly used to track the progress of these user stories.

Size estimation in agile projects

Agile process separates estimation of size from estimation of duration. Initially, estimation of size is done and it is followed by estimation of duration. Both these estimations are done at 'user story' level.

size estimation:

The size of a particular user story is determined after considering all the activities that are needed to be done to complete that user story. These activities include all the phases like Envision, Speculate, Explore and Adapt.When the user story is completed, one can assume that a part of the feature to the customer is completed. As with any estimation technique, size estimates has certain units which are as follows:

Estimation units:

1. Story point - Every user story has a specific rating or points based on either the number of days taken for it to complete or other factors. This point system is on a relative scale. There is no specific unit to calculate these points and they are actually of no physical significance. Sometimes considered as bucks per points. works better internally. consistent amount different users and time.

2. ideal time - absolute scale. calculates actual time required to complete work without any interference. generally gets calculated in days or hours. considers all working hours. actual elapse time will be greater than ideal time. easy to understand for person outside the team.

meaning of ideal time between different person could be different.

velocity estimation:

estimation of delivery capability of the team is known as velocity. velocity helps to determine scope of each iteration and total project duration. total story points divided by velocity gives number of iterations need to complete the project. iteration length is fixed hence total duration of the project can be calculated by multiplying iteration duration by number of iterations to complete all user stories defined in a project.

estimation unit:

The final unit is pure in time. mostly in number of days or hours.

Estimation techniques

Re-estimation

Advantages of agile size estimation

Disadvantages of agile size estimation

Overview

A namespace is a way to keep names organized. Lets use an analogy to file system in the computer which uses directories and sub-directories. Namespaces in this context could be viewed as the path to a file in the directory/sub-directory which can uniquely identify each file. User can create more than one files with same name in different directories or sub-directories as they are in different namespaces.[1] Another advantage of namespace is logical grouping of source code.

Above figure depicts the use of namespace in programming language. The left part of the diagram shows variable "var" used by two different contexts. Now, the context which wants to use the variable "var" should have some means of distinguishing between its declarations. This is where namespaces comes into account. As shown in the second part of the diagram each variable "var" can now be identified independently.

Types of Namespaces

Different languages support namespace either using implicit types or explicitly by using keyword 'namespace'.[2]

Implicit Namespaces

Implicit Namespaces are the abstraction defined by language itself in order to resolve name conflicts. Some of the constructs of implicit namespaces in different languages are interfaces, packages, scope, attributes,closure[3] etc.

Blocks

Blocks are often used as an abstraction to resolve naming conflicts. In many languages blocks determine scope of the variables. Hence a variable declared in a particular block has its scope within the block. Hence, we can think of a block as a namespace.[4]

Below is the example that shows how a block resolves naming ambiguities.

main()
{
      int i=5;
      ------
      ------
      {
      int i=10;
              ------
              ------
              //printing I here gives value equal to 10
      }
//printing I here gives value equal to 5
}

The above program depicts the concept of global and local variable initialization which can be viewed as a example of implicit namespace handled by programming language constructs. Disadvantage of this type of namespace is that programmer has to keep track of all variables in program and their namespaces.

Objects

In JavaScript, a namespace is actually an object which is used to reference methods, properties and other objects.Objects are all we need to create namespaces in Javascript.

Below is an example of a modules in Javascript:

var Val = {
   Hello: function() {
       alert("Hello...!!!");
   },
   Goodbye: function() {
       alert("Goodbye...!!");
   }
}
// In a nearby piece of code...
Val.Hello();
Val.Goodbye();

The above example shows the use of object to reference the methods in its namespace. Hence the functions above are called using the object.[5]

Packages

Packages can be used as a mechanism to organize classes into namespaces which are mapped to file system. A unique namespace is provided by each package which gives flexibility to define same identifier name over different packages.

Below is an example of a package in Java:

package A;
class A1  {
  int var = 4;
}
package B;
class B1  {
  int var = 12; 
}

The above code snippet shows how a package can behave as a namespace in some programming language. Here, package A and package B are two different namespaces with variable var in each of them.[6]

Modules

In some languages, different constructs are used to identify namespaces. Languages like Ruby maintains namespace at higher level of abstraction known as modules which can be thought to be similar to packages in Java.

Below is an example of a modules in Ruby programming language:

module Trig
PI = 3.141592654
def Trig.sin(x)
# ..
end
def Trig.cos(x)
# ..
end
end

module Moral
VERY_BAD = 0
BAD = 1
def Moral.sin(badness)
# ...
end
end

require 'trig'
require 'moral'
y = Trig.sin(Trig::PI/4)
wrongdoing = Moral.sin(Moral::VERY_BAD)

The above code snippet shows the use of modules in a form of namespace in Ruby language.The methods are referenced using the name of the module as shown in the code. Hence there is no clash on method name 'sin'.[7]

Attributes

XML namespaces provide method for qualifying element and attribute names by associating them with namespaces identified by unique Uniform Resource Identifier URI references. For example, Id could be in both vocabularies, employee and student, hence we can provide uniqueness for each vocabulary using namespaces to avoid conflicts.

A namespace is declared using the reserved XML attribute xmlns, the value of which must be an Internationalized Resource Identifier (IRI), usually a Uniform Resource Identifier (URI) reference.

Below is an example of a attributes as a namespace in XML:

<root
 xmlns:fruits="http://www.w3schools.com/fruits"
 xmlns:furniture="http://www.w3schools.com/furniture">
 <fruits:table>
  <fruits:tr>
    <fruits:td>Apples</fruits:td>
    <fruits:td>Bananas</fruits:td>
  </fruits:tr>
 </fruits:table>
 <furniture:table>
  <furniture:name>Sofa</f:name>
 </furniture:table>
</root>

The above XML creates the namespace "fruits" and "furniture" in the attribute of xmlns in XML. This way we define namespaces in XML.[8]

Explicit Namespaces

Namespaces can be explicitly manipulated and composed, making it quite a simple matter to combine, rename and compose packages or modules. Hence some languages use keyword "namespaces" for declaring namespaces. For example, C, CPP, PHP, C#. Below is the CPP code which depicts use of namespace keyword.

namespace Square{
  int length = 4;
}

namespace Rectangle{
  int  length = 12;
  int  breath  = 8;   
}

int main () {
 cout << Square::length << endl;  //output 4
 cout << Rectangle::length << endl;  //output 12
 return 0;
}

The above code snippet tells us the use of explicit namespace by using the keyword "namespace" in C++. It defines length in two different namespaces using the keyword namespace. When the length is referenced it is referenced using the name of the namespace.[9]

Similarly, PHP uses the namespace keyword to distinguish between identifiers.Below is an example of PHP using namespace keyword:

<?php
 Namespace A;
 Const NAME = ‘this is constant’
 Function FUN()
 {
      -----
      -----
      return _MYVARIABLE_;
 }
 Class C
 {
      function print_this()
      {
              ------
              ------
              return _THIS_METHOD_;
      }
 }
?>

The above example denotes the use of namespace keyword in PHP language. Hence in the code const NAME,function fun() and class C are defined in Namespace A. Therefore, they are referenced using the namespace A.[10]

Similarly, C# also uses namespace keyword to distinguish names. Below is the code of C# showing use of namespace keyword.

namespace A
{
  public class A1
  {
      static void Main()
      {
          B.B1.welcome();
      }
  }
}
namespace B
{
  public class B1
  {
      public static void welcome()
      {
          Console.WriteLine("Welcome");
      }
  }
}

The above code snippet shows the use of namespace keyword in C# language. Here, function main in namespace A calls to function 'welcome' from namespace B by referring its namespace_name.class_name.function_name.[11]

Conclusion

Every programming language support namespaces at different abstraction level. They are not just containers but designed to allow simple,fast and efficient usage and understanding of the code. Namespaces actually provide luxury to declare multiple variable with same name which in turn protect code with name clashes. Using namespace generally gives a better structure to program which makes easier to maintain when the code length increases. In summary, different languages have different methods of providing namespace functionality be it explicit or implicit to provide better coding experience to the user.

References

References

  1. NameSpace
  2. Explicit Namespaces
  3. Closures
  4. Code blocks, execution frames, and namespaces
  5. Namespaces in Javascript
  6. Namespace vs. Packages
  7. Ruby Modules and Mixins
  8. XML Namespace
  9. Namespace in C++
  10. PHP Manual by Mehdi Achour, Friedhelm Betz, Antony Dovgal, Nuno Lopes, Hannes Magnusson, Georg Richter, Damien Seguy, Jakub Vrana
  11. Namespaces in C#