Professional Illustrate the Specifications before Jumping to Code

Professional Illustrate the Specifications before Jumping to Code

If you want to design a program, you might want to know first what the program supposed to do.

Image for post

Photo by Scott Graham on Unsplash

If you want to design a program, you might want to know first what the program supposed to do.

These instructions are called specifications and they might come from the customer, the end user or the analyst team.

They might be provided it to you in informal text, in a structured document, or using a formal mathematical notation.

In this article I will focus on Mathematical notation.And I will use two notations,mathematical logic and OCL.

The brand of mathematical logic we will use is called by various names,including first order logic,FOL,and predicate calculus.

FOL, enables you to precisely express propositions, combine them using like and and, or or not.

and quantify them using logical connectives using the operators for all and there exists.

OCL,Object constraint language,which is a part of UML.

OCL,provides a syntaxe for FOL that can be used to annotate UML diagrams.

Typically break the specification into three pieces,called the signature,the precondition,and the postcondition.

Signature:

Gives the name of the program,the names and types of the input arguments and the name and the type of the results.

Example:

Vector Y = SORT(Vector X).

The sort takes a single argument named X that has the datatype Vector and produces a result Vector Y.

X and Y have explicit names so we can use them in the pre and post conditions.

Precondition:

We have to make sure that the x element we are passing there, is not negative.

So,x > 0.

We are specifying the behavior of the function in terms of what does this function mean when it gets expected arguments?

If you wanted to have a variant.which worked on any argument.But raise an exception or produced a return code if x was less than 0. We can specify that as well.

PostCondition:

The postcondition is also an insertion.

It says what must be true about the output produced by a function.

Typically this means expressing how the output relates to the input.

Postconditions for Sort:

1- The output vector Y must be ordered.

2- The contents of Y must be the same as the content X.

OCL (Object Constraint Language)

So, when we look at UML we look at diagrams.But, diagrams don’t tell the whole story.There are places in the specifications and the designs of your system where you need more details. And that is what OCL was designed to provide to designers.

OCL, is a language,it’s not a programming language.It’s a specification language. It’s a declarative,it’s strongly typed,and it allows you to specifiy the functional details of system properties.

OCL consists of means to express constraints plus some collection classes add the ability to navigate around the various classes of relationships in your diagrams.

Constraints + collection classes + UML diagram navigation.

OCL is a mature technology is an official part of UML and supported by various tools.such Rational Rose,ArgoUML,Eclipse,Poseidon,Enterprise Architect and so on.

Why Do we Need OCL ?

The diagrams are great, at describing structural relationships and behavioral descriptions.

software-engineering bootcamp technology programming software

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Software Developer vs Software Engineer — Differences: Bogus or Real?

In this article, see if there are any differences between software developers and software engineers. What you’re about to read mostly revolves around my personal thoughts, deductions, and offbeat imagination. If you have different sentiments, add them in the comment section, and let’s dispute! So, today’s topic…

Interested in Learning to Program? 13 Reasons to Start Now

Software development is something that is gaining popularity at lightning speed with the development of technology. The demand for regular developers is high compared to most other mainstream professions. But, what are the other reasons for learning to code?

Coding Bootcamp or University to Become a Software Engineer?

Coding Bootcamp or University to Become a Software Engineer? - Which one is more bang for your buck?

How to Have a Solid Start in Software Engineering

How to Have a Solid Start in Software Engineering. My first ever software development project an A-Z programming experience!

Science and Engineering in Software Architecture

Science and Engineering in Software Architecture - We are passing through tough times, “The moment everything changed” with COVID-19, quarentine, people trying adapt their day to day…