Monday, September 8, 2008

Modeling Languages

Modeling languages, like any language, have Syntax & Semantics . The Syntax defines the structure any instance model in it can take. each language will have an abstract syntax, and a number of concrete syntax it could be represented with.

Syntax:

concrete syntax can be visual or textual, depending on how we would like to describe the language. A modeling language can have both a textual and a visual syntax. ( think of to a very well defined toString method ) .
Visual Languages syntax can be divided into two streams:
  1. Connection based or Topological: where position and size of different language elements doesn't matter ( irrelevant ). the more specific next level in this branch is Graph based visual languages ( state charts ) , and the next is Plex languages ( DEVS or CBD) where the Arch attachment area have significance ( via ports for example )
  2. Geometric: where position of elements in the model instances does matter. a subset of this brach would the box based languages ( where no overlap is allowed ) (Snieder graphs). the next subset is iconic languages where overlap IS allowed, and the most specifc in this branch are string ( textual ) languages like programming languages for example.
Another thing should be mentioned is that all concrete syntax of a language are translated into the abstract tree syntax. which the essence of a model instance, and will be used in mapping to the semantics domain.
Note: the process of transforming a concrete syntax into the abstract is called Parsing. and the inverse is called pretty printing.

Semantics:
Each language has semantics which is defined by the semantics domain . for example if we take a sentence "2+3" for example, will map into "5" in the semantics domain.
The mapping function M[[ ]], can be in two forms ( they are both identical ):
  1. Denotational : like a translator describes "What"
  2. Operational: describes a procedure of "How" to compute . like a program.
The mapping function has to be unique ( meaning for each abstract syntax it will produce a mapping, and total, meaning that it can give a mapping for any valid input. note also that non-determinism here is ok.

Sunday, August 17, 2008

Agile 2008 - sessions

So I would like to list the sessions I went to, at Agile 2008, in Toronto last week, and what I thought of them. ( if you would like the full description of each session you can look it up on the agile website .
__________________________________________
Session: TDD Clinic: BDD, Ruby, & Rails:

This talk was a tutorial on how to use BDD (behaviour driven development) within the Ruby on Rails (RoR) framework.
It was a very good practical introduction into TDD (Test Driven Development) in general as well as specifically for RoR.

TDD gives us:

  • Automated software testing
  • Confidence that our software does what we say it does
  • The ability to make changes and verify that it hasn't affected other functionality (e.g. NOT like our current LIMS)
____________________________________
Styles of TDD: First Tests

This was a rather useless “workshop” where we sat around talking about how to start writing tests.

If anything, it shows that we should be careful who we consider to be "experts" and who we hire for training.

____________________________________

Session: XUnit Test Patterns and Smells; Improving Test Code and Testability Through Refactoring

  • Design Patterns And smells
  • Unit Testing code And smells
  • Design patterns of the testing code
This is useful in any further activity that should involve unit testing. It will also help enhancing and avoiding pitfalls in sherpa unit testing code and approach. it was definetly a worthwhile talk. I recommend it for anyone who is struggling with maintaining her testing code.
____________________________________

Session: Domain Specific Testing Languages

  • Domain Specific Testing Languages (DSTLs) express customer requirements as tests with the scope, granularity, and transparency you need.
  • push users to drive their test cases by:
    • understanding their terminology.
    • provide them with a language to describe what they want their application to do.
    • for example : how do you describe a test case for brushing your teeth
____________________________________

Agile Development Practices for Dynamic Languages

This talk was on how to apply AGILE practices for dynamic languages.

It turned out to be less than useful as the speak spent most of the time discussing the differences between Static and Dynamic typed languages.
____________________________________

Skills for the Agile Designer

This session focused on developing skills used when starting a new Agile project.

The exercise was to write up the main challenges of a project individually and then discuss in a group the challenges we saw.

It acted to illustrate the differences between peoples backgrounds and experiences. Furthermore it aided in bringing forward challenges that team members did not even think of initially.

____________________________________

Session : Exploring user stories through mind mapping

this session is highly recommened, for more details on this go to this page from the speaker.

Friday, August 8, 2008

Agile 2008

I was away for the past week at the Agile 2008 conference, which took place in Toronto, Canada. it was a wonderful opportunity for me to attend this great conference. I will try to post few summaries of the most interesting names and sessions that I have seen.

Saturday, July 26, 2008

Permission system design - Part1

I have been trying to implement a decent permission system in rails. there are many plugins out there. the most useful one " to my needs" was the authorization plug-in. I am trying to solve this issue in the context of ruby, and rails ; but ideally the design of a permission system is a general well known problem.
Let's take for example a system that has multiple modules, like for example, calendaring module and room reservation modules, there is multiple levels to the permissions that can be granted :
  1. Per module permissions : where a permissions are granted to users to create_calendars, or view_calendars. for the other module these could be like delete_reservations .. and so on.
  2. Per object permissions: where i wanna give permissions on a specific object or instance, like for example if we have a calendar called employees, and another called management, then i would like to give a permission edit_calendar on the employee calendar for the hr user, and an edit _calendar permission to the personal assistant of the manager on the manager's calendar.
  3. Per field permissions: for example i want to give the permission edit_calendar_name to only the administrator user. Note that this can level could work hand in hand with the previous point.
  4. Per object-user role permissions : Assume in a reservation you will have two roles, creator of the reservation, and guests. then I would give reservation_view_creator to a user A. this will then restrict the user to viewing only reservations to which he is the creator of . this as you can see is more of restriction rather than a permission. i.e : granting reservation_view_creator will limit the viewed items rather than increasing them.
  5. Now take everything i mentioned, and add to it user group based permissions. like in most system each user will have a role (admin, moderator, guest). so the permission system should understand if a user is part of a group that has a permission, she should inherit the permission too. also in point 4, the permission reservation_view_creator_group should allow users to view all reservations where they OR a person in their group ( role ) is the creator. this is related but not the same as number 5.
This is the problem domain and the solution is to follow.

Tuesday, July 22, 2008

Model Based Testing Vs Test modeling

Model Based Testing
Is just another testing concept. it's mainly built around the idea of using the models which describe a system to produce test cases to test the system. in UML we can look at a system's statecharts diagram to generate test cases that will guarantee state coverage for example. or even other coverage criteria. another example is use case based testing, which uses the use case model to generate high level user acceptance test cases.

Test Modeling
Test modeling describes an approach to model the overall testing activity of a system. specifically the testing system could be considered a seperate system of the testable system. and then it can be modeled through structural, behaviour and implementaion diagrams. in a nutshell test modeling is all about descibing testing concepts of a system as models that go hand in hand with the system under test models.

Tuesday, July 1, 2008

Model based design

Modeling:
Modeling is mainly about abstraction, and describing concepts from a different level. like in UML for example, we use boxes to represent classes, arrows to represent associations and relationships.
so when we build a complex system, before we would right the source code for it, we start sketching out different components of the system, and how they believed to interact and so on. then we use these boxes as a reference that we use while writing the source code. in fact these models will always help us to look at the big picture from a different abstraction layer.
this activity is called modeling. in software engineering modeling is mainly based on UML ( unified modeling language) but not restricted to it. in general we can call the language that defines the different models or components that we can use a formalism. UML class diagram, for example, is considered a formalism that lets you model classes and their associations and inheritance or even compositions. UML statecharts is another formalism that allows for modeling the state flow and interactions of a system. of course if we look at other systems we are not limited to UML formalisms, for example Petri nets, or DEVS amongst others are also powerful formalism with different purposes.

Meta modeling:

A formalism like the UML class diagram contains many elements. for example a class is an element that has a type class, has a property called name, and can have many attributes. it can also have many methods each with a qualifier ( public , private or protected) . and so on.
but where is all these things described and specified ? they are in something called the UML class diagram meta model. in general a meta model describes the grammar of a language, or a formalism. in the meta model also you can define the graphical representation of the elements of the formalism . for example you can choose to represent the class by a box with a header that includes its name. and so on.


Domain specific modeling:
Domain specific modeling is just normal modeling. the main thing that is involved here is that the modeling environment ( the formalism ) that will allow the user to build models is built specifically for the desired domain. to make this simpler here is an example . let's say i am a modeler and i wanna build a domain specific modeling language for building traffic systems ( arguably, i am doing that so that i give later to traffic system experts so that they can use it to build a traffic system model for the new city and analyze it). Then I can define this traffic modeling system by specifying the different elements it can have and the different links it can have between them. its really like designing your own UML language. so for example for traffic networks i can talk about defining a domain specific language that has road segments, traffic lights and car generators . i can then describe some constraints like for example a road segment can only be connected to a maximum of two other road segments. or a constraint that i can only connect a car generator to one road segment at any time. by doing this i take away some of the complexity that whoever is designing a traffic system doesnt care about. in this case the user will only worry about the problem domain ( building a traffic system) and not worry about how this system will map back to running code.
However, someone will need to worry about this mapping into a running program as the upcoming post on model transformation will describe.

Wednesday, June 4, 2008

events calendars in rails appllication

I am currently working on a rails application, which is supposed to allows users to create events (holidays) and view shared events on a calendar. the requirements are simple. the required calendars are merely views. there is no interactivity needed other than providing links to the events.
so like any rails enthusiast, i went to Google and assumed i would find plenty of stuff to help me. it turns out my expectations were too high.
i found one worth while simple rails integrated calendar, its the calendar helper, which is bundled as a rails plugin. you can find it here : http://topfunky.net/svn/plugins/calendar_helper/
the plugin provides a function that can be embedded in a any view to create a calendar. its CSS is not that good. it however provide a starting point.
another option we had is embedding a Google calendar. the idea is that the rails application will have a Google account from which it can manipulate events on the calendar. Google calendar does provide a lot of integration libraries in many languages( php, .net ). sadly though, none for rails or ruby. there was one plugin for Google calendar that was available for rails (benjamin.francisoud.googlepages.com/googlecalendar). we gave it a shot .
problems we faced :
the plugin doesn't pick up the event id (provided by google ) after inserting. so you can really update events ( you have no reference id to them) . and even API doesn't support any of this functionality. i.e the plugin only lets you insert events ( no edit, deletes, or updates) . (this is what we found at the time of this post).
We are working on getting this calendar into a shape, and we will release the new code once we think its mature enough and usable by others.

Friday, May 23, 2008

PeX : Automated Test generation for .net

This tool is a greate test generation tool, i have seen it way before, but it was just released . it was written by a very talented guy called de halleux . i believe he is from Belgium . he is the same guy who wrote the initial MBunit testing framework for .net .
This tool is highly recommended....check it out : http://research.microsoft.com/pex/

Wednesday, May 21, 2008

Model based testing

1. An overview of model based testing:
Model based testing approach basically attempts to automate the test design rather than the execution. this is done b generating tests automatically of the SUT. in general, we usually go from requirements into test cases. but here the approach is to model different aspects of the system and then generate test cases to test that model. MBT is a black box testing with some functional and up to system testing.

The France telecoms example: a service let you enter a phone number and the system will produce a name and an address that is associated with that number. A finite state machine model could be written to model this use case.

To generate tests for this use case, we could for example take a random walk or a path through the different states in the state automaton, by defining the actions at each stage. A smarter algorithm to archive coverage exists, for example the Chinese post man algorithm. or trying all the transitions in a state, one by one, like testing all the interactions.
other algorithms are testing all variants of a given use case, which is sort of user directed.

there is two approaches to execute these tests:
off-line : generate test cases and store them in files, execution are separate .
online : generation and execution are tightly coupled. this is very important when SUT is indeterministic. so essentially you generate a test case, and then execute it. waiting for the result before generating the next.

Benefits of MBT:
the real cost saving is in test design: modeling time is arguable less than manual test design time. other benefits include enhancing requirements from the raised questions throughout modeling. it helps to automate traceability. the only draw back is modeling, since it can be costly and needs expertise.

2. Black box Vs White box models:

Test generation algorithm:
black box model:
in the black box model we need to generate tests from a model inside a black box, which means we don't see the internal of the model. it however, always tells us the current state, and provides a list of possible inputs. we then explore the model and find out about the behavior from the different input sequences we put in, and the corresponding state.

in white box model:
it tells us upfront what kind of behavior it has. by looking at the internals of this model, one can perform full analysis on all possible paths it can take. and thus try them all.

To model complex systems we use extended finite state machines(like a programming language with variables, guards). which could give us much more expressiveness.

Pros and Cons:
black:
uses executable actions, which means we can use any language that is executable( java ), but harder to understand since you cant see the model but rather have to explore it.

white:
uses unfamiliar notation such as UML/OCL, but easy to analyze .
you can have some sophisticated reasoning. and plan the paths ahead.

3.Black Box model example

modelJUnit : MBT with black box. allows you to write models in java (familiar) with full power of the language ( more expressivity) integrate well with JUnit ( focuses on unit testing)
provide simple test generation algorithms (random walk, greedy walk ...etc)

Imagine we wanna test the set element of the java elements . simplify to use only two elements. then we can model this FSA in java, by modeling the state as in having elements in the two slots by booleans. and model the transitions as methods that are annotated as actions.
so then a test user will choose the test generation algorithm, and the model to generate the tests.

so then a 150 action sequences get produced, which are the test cases . now these tests can be used to do offline or even online testing, but we need to have an oracle to tell us if the tests are passing . like for every change the test model performs, the SUT performs a change. we need to check that these are matching.

now to really mesure how good these tests that were generated, is through a tool. this is done throught the concept of mutation. so this tool will take on your junit tests and run them on mutated code, and if the test doesnt cover the mutation then the test is not really that good. its realted to code coverage but not the same.

4.white box model example

model in UML, then export the tests from that and going the test designer to generate some tests, and export them into some executable language to the to execute them . imagine we have a library system, we model it in UML, then we model an object diagram to generate test data. we also describe the methods in OCL. now to generate tests we can use the constraints in OCL to guide us thought the right path in state machine.

checkout this awesome Google talk :

http://video.google.com/videoplay?docid=5521890509476590796

Friday, May 9, 2008

Trac architecture

Trac, is one of the best ever software projects management tool, it has a unique extensible architecture . I took the chance of introducing its architecture to my software architecture class. here is the presentation.

Wednesday, May 7, 2008

A Model based, Model transformation testing framework

I did a presentation on model transformation testing last week ...and I am posting it here



Tuesday, April 15, 2008

Procedural modeling of city generation:

As the game industry is advancing, and the video cards are becoming more powerful, the need for more powerful expressive graphics obviously increase. using modeling techniques to generate such graphics is desirable as it reduces the costs.desire for more details in the graphics .using generation techniques, each graphic can be generated by calling a function with some parameters. these parameters could determine the shape of the tree , or its color . or even some patter it has. and by such making it different form other generated trees. here is few approaches :
  • L-system: used to model plants,it uses rewriting of the graphics by modeling bacteria division populations.
  • Perline noise : uses parametric control and allows for minimal storage management.
  • Tiling : using random distribution function, for placing tiles or objects to create textures .
  • Veroneri Texture basis : place dots randomly , draw lines to produce cellular textures .
  • the main goal is to look realistic rather than behave realistic .
so after looking at this , the question is this ? can we extend this to model generation of complete cities ?

Heterogeneous Modeling and Simulation in Ptolemy:

Ptolemy is a modeling tool that is built entirely on Java. one it's main features is allowing heterogeneous modeling. what this means is that it allows to model different system components using different formalisms. this is especially important as it allows for more power in modeling. like for example in embedded systems where each model represent one aspect of the system( some continuous and some are discrete). it certainly limits the modeler if it was only one formalisms she is doing .
Ptolemy's approach is a hierarchically heterogeneous modeling approach, which means that at each level we use the same modeling formalism.

Monday, April 14, 2008

Modeling of Aspect Weaving

Everyone who has worked with Aspect oriented programs, that are complex enough, would understand the nightmare that they can cause! it's very easy to lose track of what aspect get applied when and in which order ! so a natural approach to deal with such programs is to use modeling techniques.
normally any behavior can be modeled in programs as a sequence diagram. so in OO, we model a certain behavior using such a diagram , but in case of Aspect weaving , it would become more complicated . as the behaviour might change if there is a point cut at any location through out the execution. so it would be ideal to describe such aspects , by class diagrams for thier structure . and by point cuts and advices for thier behavior. then we can use a "model transformation" to take this building block and apply it on a graph. to produce the sequence diagram that represent the actual execution with the aspect weaved in .

Modeling of Aspect Weaving

Everyone who has worked with Aspect oriented programs, that are complex enough, would understand the nightmare that they can cause! it's very easy to lose track of what aspect get applied when and in which order ! so a natural approach to deal with such programs is to use modeling techniques. normally any behavior can be modeled in programs as a sequence diagram. so in OO, we model a certain behavior using such a diagram , but in case of Aspect weaving , it would become more complicated . as the behaviour might change if there is a point cut at any location through out the execution. so it would be ideal to describe such aspects , by class diagrams for their structure . and by point cuts and advices for thier behavior. then we can use a "model transformation" to take this building block and apply it on a graph. to produce the sequence diagram that represent the actual execution with the aspect weaved in .

Reuse and API

the most efficiet approach to building systems today, lies within reuse. as open source software grows, and we get better and better open source applications like ( all the php(s) in the web application world) . so now you are faced with requirements to build a new system, you could easily see that most of the functionalities were already implemented in open source, maybe not all but most . now if you are smart enough you will think of reuse. which will make the task easier. and the developement time shrinks. but we are still afraid of such endeavor , and most developers rather rebuild the system from scratch ! And i am wondering about why this is the case?
my conclusion is that : in order to reuse any "component" in software, you need an API for it, a very good API, that is well documented! and in general building a component with mindset that is targeted on reuse ! it's like design for testability really, if you dont think about it early on its hard to achieve !

there was a vey nice google talk about designing good APIs and why it matters to do so : you can find it here: http://youtube.com/watch?v=aAb7hSCtvGw

Wednesday, April 9, 2008

XMULATOR

is a network archeticture simulator, normally netwroks can be indirect or direct (butterfly Vs hypercube ). and could have different switching methods: store & forward, wormhole( where messages are divided into flits that get sent) and there is many potenial bottelnecks. in routing algorithms there is a huge deadlocking concern. that's why simulation of these network archeticture becomes important as for analysis purposes ! Xmulator ( XML + simulator) provides a simulation envirnoment for networks. it's implemented using new and modern(object-oriented) programming languages.(implemented in C#) . it defines topologies using XML. and uses red black trees as data structures. where the first layer is generation of random numbers and data structures. it has many features, like listeners based integration which increases the extensibilty ( listeners are defines the events) . the project will attempt at writing a MT ( model transformation) from atom3 models into an XML file which is the input of the simulator.

Thursday, March 27, 2008

Adobe opens shop on Web-based Photoshop Express

so adobe photoshop is finally online ... and free for anyone to use http://www.news.com/8301-10784_3-9903446-7.html

Tuesday, March 18, 2008

Hybrid (Differential Equations - Statecharts) modelling in Anylogic

Anylogic is a modelling tool which allows modeling systems that are hybrid ( continuous and discrete timed systems) . used mostly for agent based modelling environment. in agent based modeling, individual centric approach is what used, i.e we model the cars rather the system, which will allow us to model instances of the model differently .
In Discrete event modelling, we use statechart with a timer (to generate events) and maybe some plain variables . where as in continuose systems modelling we describe the model using a set of DE that can be solved given any point of time to get a perfect simulation .
this type of systems are especially important in agent based modeling which allows for more realistic simulation . while keeping the individuality of different agents .
check out this great simulation tool at : http://www.xjtek.com/

Monday, March 17, 2008

Statecharts modelling of TankWars

due to growing market share of the game industry throughout recent years, More complex AI in games is in high demand. on of the main requirements is then high reusability, which happens to be one of MDE preaches. so EA sports launched a compeition to write the AI function of tanks in a tank war game. each tank had an AI function that was to be called with environments parameters. it was a time sliced approach which needs simulators so statecharts, was used to model behavior and a class diagram for structure to model the tank game. the tanks needed to avoid obstacles, detect enemy and remember some map information. the AI of the tank models the pilot. so a whole bunch of statecharts that describe the tactical strategy . the simulator cals the AI function , and passes the environment variables. appropriate level of abstraction is introduced , an evet based formalism is the most useful/applicable , statechart ( modularity , event based , simulation and code generation ) .

solving Dynamic Non-causal Algebraic Equation Sets using modeling

Solving algebraic equations using modeling techniques could ease up the process greatly, it can help for effecient and optimal time . in essence a system of equations could be considered a model. and then this model can refactored using simplification rules( like for example make all the terms in the left hand side, and reduce the number of operators by factoring out common terms) .

this really looks like we are refactoring the equations, or the model, its eventually the same equation. but this refactoring is systematic and will lead to reveal the shortest way to solve this model .

Monday, March 3, 2008

Programmer graph rewritting

The recently advocated MDA ( model driven architecture ) approach in software engineering, is based upon Meta models and model transformations. and given that we can represent models as graphs we then can argue about graph rewritings as model transformations.

a classification of these transformations include the following :
  1. Unordered : set of rules which get applied at no particular order. and the transformation halts when no more rules can be applied
  2. Ordered : set of rules which get applied at a particular order or partial order.
  3. Even-driven: the order is driven by external events or interrupts.
Programmed graph transformations are ordered and structured rules, that can incorporate programming languages constructs in thier textual form .

An overview of graph transformation systems follow the same concept a LHS graph is swapped with a RHS graph . attributes transfer from the original to the target can also by done. some conditions can be enforced on certain rules using OCL.


motif transformation language is based on DEVS, it is being developed by Eugene and professor Hans at the school of computer science at mcgill university. essentially it allows the users to model graph transformation in the ATOM3 environment, and then compile this rules as DEVs which adds the concept of time to them, and allows for better analysis.
for more information check eugene homepage http://moncs.cs.mcgill.ca/people/eugene/

Friday, November 30, 2007

Resetting mysql root password on a mac

i was trying to reset the root password for mysql on my mac the other day , but apparently it was very easy to do ......... here is how to do it :
run the follwing command:

sudo mysqld_safe --skip-grant-tables --user=root

this will allow you to login to mysql using the root username without specifying a password..

shell>mysql -u root

then you can update the user privileges in your db for your root.......voila.

Monday, October 22, 2007

Software Components

Software components:
Definitions:
  1. A unit of composition with a specified interface, that can be deployed independently and is subject to composition with other parts.
  2. A coherent package of software implementation that :
    1. Can be independently developed and deployed
    2. has explicit and well specified interface of services it provides
    3. has explicit and well defined set of interfaces for the servies it expect.
    4. can be composed with other components.
Component, Model, Infrastructure:
usually there exists an abstract component Model that defines the interaction and composition standards. then this component model is implemented in a framework like implementation that allows for conformed components to plug into .
Example :
  • Component Model : Unix
  • Implementation : Free BSD
  • Components: Applications
Some of the problems this architecture ran into (for OS's) is the applications are rarely used as building blocks, and the lack os the domain specific standards, in that the services an OS provides is too general to be used effectively.


Basic Elements of Component Model
  1. Interfaces: Specification of component behavior and properties
  2. Naming : Global unique names for interfaces and components
  3. Meta Data: Information about components interfaces and thier relationships
  4. Interoperability: Communication and data exchange among components from different vendors.
  5. Customization: Interfaces for customizing components
  6. Compositions : interfaces and rules for combing in components to create larger strcutrues
  7. Evolution Support: rules and services for replacing components or interfaces by newer versions
  8. packaging and Deployment:
Interfaces:
In certain scenarios a more accurate specification of the components behavior can be acheived through contracts rather than interfaces .

Objects VS Components:
  • Components usually use persistent state rather than local state
  • Components usually have a more extensive set of intercommunication mechanisms rather than messaging .
  • usually have more complex functions are their interfaces .
  • Components names are not types
  • Components implementation is more hidden
  • Components standards.
Application Frameworks:
a framework could be seen as the context in which we glue software pieces together, it's in general a reusable design of a system, or a skeleton on an application which can be customized by an application developer.

Eclipse framework ( www.eclipse.org)

Are Frameworks the same as design patterns ?
major differences lie in:
  • Level of abstraction
  • DPs are smaller architecture elements
  • the level of specialization
Reference: Prof M Robillard


Tuesday, October 16, 2007

Activating Aspects with AspectJ

lets say you are building a library of Aspects, that could be used by somebody, you would come across the following problem : how does the client who will be using this library decide which aspects to activate when ? two solutions (let me know about others):
  • Define your aspects as abstract aspects, then the user will easily decide to activate some aspects by extending these abstract aspects . this is a nice way of doing it. but the problem with this is that the client will need to understand aspects and AspectJ .
  • define the point cuts in the aspects to act upon certain interfaces( which are deployed also with the library) , so then the user activates certain aspects on certain objects by implementing them interfaces . now the draw back to this is that let's say you wanna have some aspects that act upon the whole system your sccope will be harder to define .