. Documenting Objects in MATHS MATHS predates the OO explosion of the middle 1990s. However it had already incorporated several ideas that have been absorbed into OOP/OOA/OOD. Inheritance for example was present in some of the very earliest notes prepared like this in the late 1960's. An object has both a state and a pattern of behavior. Both of these must be documented: . Static Aspects If you only look at the possible states that an object can have then you are looking at a static picture... and one that is easliy expressed by the record structures used in MATHS: .See http://www/dick/maths/intro_structures.html For example a point in the Cartesian plan might be described as: POINT::=following, .Net x::real. y::real. .Close.Net These 'nets' can also be abbreviated and used in expressions like this: Net{x,y:real} The static interrelationships between objects is treated using the MATHS techniques that also apply to "data bases": .See http://www/dick/maths/math_13_Data_Bases.html . Extensions and subsets You can extend and/or subset Nets: POINT2::= \$ \$POINT with following, .Net arg::Angle. abs::Positive & REAL. |-x*tan(arg)=y. |-arg^2 = x^2 + y^2. .Close.Net which adds polar coordinates. As a result POINT3 is .Net x::real. y::real. arg::Angle. abs::Positive & REAL. |-x*tan(arg)=y. |-arg^2 = x^2 + y^2. .Close.Net . Behavior The behavior of objects is expresed in diffeernt ways by different methodologists. One technique is to list and define the operations that apply to objects of a given class. THis can be like an Abstract Data Type. Or it can be describing the changes that can occur to an implicit object .See http://www/dick/maths/intro_dynamics.html MATHS can use the Z (`Zed`) approach of describing change in a complex object as a Net (schema) that contains a description of the start and end of the change and the constraint beteen them. The prime "'" indicates the final or future value: For x0,y0:real, MOVE(x0,y0)::=following, .Net |- POINT. |- POINT'. |- x'=x+x0 and y'=y+y0. .Close.Net Notice that the `arg` and `abs` of a POINT2 will always be adjusted when either `x` or `y` changes. For x0,y0:real, MOVE2(x0,y0)::=following, .Net |- POINT2. |- POINT2'. |- x'=x+x0 and y'=y+y0. .Close.Net And `vice versa` -- if a change rotates the point p.arg = x.arg + 45.degrees, then p.x, and p.y will change. Operations::Partly_Baked_Idea=following, .Net Another (as yet informal) convention could be to include .Key object-oriented operations inside a Network of variables and predicates. For example POINT3::=following .Net x::real. y::real. arg::Angle. abs::Positive & REAL. |-x*tan(arg)=y. |-arg^2 = x^2 + y^2. For x0:real, setX(x0)::operation = (x'=x0). For y0:real, setY(y0)::operation = (y'=y0). For x0,y0:real, move(x0,y0)::operation = (x'=x+x0 and y'=y0+y). .Close.Net POINT3 p1: \$POINT(x=1,y=1). p2:= p1.move(-1,-1). or p3:=p1.move(1,1). The above is a Partly_Baked_Idea. .Hole OperationOnObjects .Close.Net . Dynamics Davaid Harel invented the Statechart as an improvement of the Finite State Machine and these have been put into the UML. These can be expressed in MATHS but Jackson Life History Program technique gives a cleaner structure to problems. It also means that the states are deduced from the problem rather than guessed. Here the possible lives of an object in the class are written as structured running program. Each real object is a thread executing the program. .See http://www/dick/maths/math_75_Programs.html The threads run for as long as the real object exists... when the program is not running the object must be saved in a persistent form. When the real object becomes active the saved stae is restored and the life-history is restarted. The communication between these (highly poarallel) objects is close to that in CSP. . Scenarios Scenarios can described in a simple structured form using: .See http://www/dick/maths/intro_ebnf.html . Inheritance If you have already written the documentation for something called N then N and w is the result of adding a condition or well formed formula to N as a constraint. You can add a whole set of features to a piece of documentation called N by N with{ new_features}. . Generics and Templates Any loosely bound terms in a piece of MATHS documentation is generic and can be replaced by a more tightly bound and so specific form. . No Privacy VAriable can be hidden by using an existential quantifier, if needed. But this is pretty rare. . More .See ./math_12_Structure.html