KEMBAR78
Key points of good software programming | PDF
Key Points of Good Software Programming
A Practical Approach
São Paulo, Brazil, January 2014
Márcio Luís da Silva
Senior Software Developer
at 7COMm, Brazil
Information Systems Bachelor Degree
Centro Universitário Fundação Santo André
The author
This Presentation
silva.luis.marcio@gmail.com
About
Software developers.
The audience
Is about refactoring, polymorfism, design patterns, programming languages,
automated code generation, componentization and reuse.
All initiatives were implemented in real life. Except for the automated code
generation tool, All implementations were used at the moment they were
collected.
Key Points of Good Software Programming
● Software Objective
● Refactoring
● Polymorfism
● Design Patterns
● Computer Programming
● Automate Code Generation
● Componentization & Reuse
● Best Practices in Software
Content
● Good Software
● Simplicity
● The Software as a Product
● Complexity
Key Points of Good Software Programming
Road Map
● The code
● Productivity
● Competitive Edge
● Communication
The good software
Key Points of Good Software Programming
External characteristics [2]
● Correctness
● Usability
● Efficiency
● Reliability
● Integrity
● Adaptability
● Accuracy
● Robustness
[2] Steve McConnell. Code Complete, A Practical Handbook of Software Construction
Internal characteristics [2]
•
Maintainability
•
Flexibility
•
Portability
•
Reusability
•
Readability
•
Testability
•
Understandability
Profitable
Customers Suppliers
Good
experience
The Good Software
+
Many programming projects are still operated like machine shops.
[1] Frederick Brooks. The Mythical Man-Month
•
Common development and maintenance of the general-purpose programming
tools.
•
High-level language;
•
Sharing and protection for data and programs, extensive library management;
•
facilities for cooperative work
The essential problem is communication.
Successful Improvements
The Technological Scenario
Key Points of Good Software Programming
Simplicity
1 public MyEntity save(final MyEntity entity) {
2 validator.assertValid(entity);
3
4 // Decide to update or insert
5 if (entity.getVersion() != null) {
6 // find by the business id
7 MyEntity persistedEntity = findByName(entity.getName());
8
9 /**
10 * Check if exists.
11 */
12 if (persistedEntity == null) {
13 throw new ConcurrencyException(entity);
14 }
15
16 if (!persistedEntity.getVersion().equals(entity.getVersion())) {
17 throw new ConcurrencyException(entity);
18 }
19
20 MyEntity updatedEntity = dataManager.merge(entity);
21
22 dataManager.flush();// Force flush to capture potential exceptions
23 dataManager.evict(updatedEntity);
24
25 return updatedEntity;
26 } else {
27 // find by the business id
28 final MyEntity persistedEntity = findByName(entity.getName());
29
30 /**
31 * Check if exists.
32 */
33
33 if (persistedEntity != null) {
34 throw new ConcurrencyException(persistedEntity);
35 }
36
37 try {
38
39 dataManager.persist(entity);
30 dataManager.flush();// Force flush to capture potential
41
42 } catch (final DataIntegrityViolationException e) {
43 throw new ConcurrencyException(entity);
44 }
45
46 dataManager.evict(entity);
47
48 return entity;
49 }
50}
25 occurrencies found
Simplicity
1 public T persist(T object) throws PersistenceException {
2
3 if (checkUpdate(object) != null) {
4
5 getHibernateOperations().saveOrUpdate(object);
6 return object;
7
8 } else {
9
10 checkUnique(object);
11 getHibernateOperations().persist(object);
12 return object;
13
14 }
15 }
16
17 private T checkUpdate(T object) throws PersistenceException {
18 Serializable id = JPAUtils.getId(object);
19 Object version = JPAUtils.getVersion(object);
20
21 T persistedObj = null;
22
23 if (id != null) {
24
25 persistedObj = getHibernateOperations().get((Class<T>)
this.entityType, id);
26 if (persistedObj == null) {
27 throw new ConcurrencyException(getFailedEntity(object));
28 }
29 getHibernateOperations().evict(persistedObj);
30
31 }
32
33 if (version != null && persistedObj != null) {
34
35 Object persistedVersion = JPAUtils.getVersion(persistedObj);
36 if (!persistedVersion.equals(version)) {
37 throw new ConcurrencyException(getFailedEntity(object));
38 }
39 }
40
41 return persistedObj;
42 }
43
44 private T checkUnique(T object) throws PersistenceException {
45 String[] propertyNames = JPAUtils.getUniqueProperties(object.getClass());
46 if (propertyNames.length > 0) {
47 Object[] propertyValues = JPAUtils.getUniqueValues(object);
48 DetachedCriteria criteria = DetachedCriteria.forClass(object.getClass());
49 for (int index = 0; index < propertyNames.length; index++) {
50 criteria.add(Restrictions.eq(propertyNames[index], propertyValues[index]));
51 }
52 if (!hibernateOperations.findByCriteria(criteria).isEmpty()) {
53 throw new ConcurrencyException(getFailedEntity(object));
54 }
55 }
56 return object;
57 }
The DRY implementation
Simplicity
Benefits:
● Less code to correct defects;
● Less code to change;
● Less code to test.
Internal characteristics [2]
•
Maintainability
•
Flexibility
•
Portability
•
Reusability
•
Readability
•
Testability
•
Understandability
Simplicity
●Once and only once [3];
●DRY - Don't Repeat Yourself [4];
●Duplication represents additional work, risk, and
unnecessary complexity [5].
●The focus on eliminating duplication can take us a long
way in the direction of simplicity [6].
[3] Extreme Programming: A gentle introduction (http://www.extremeprogramming.org/rules/simple.html)
[4] Andrew Hunt, David Thomas. Pragmatic Programmer, The: From Journeyman to Master
[5] Robert C. Martin. Clean Code. A Handbook of Agile Software Craftsmanship
[6] Martin Fowler. Is Design Dead? (http://martinfowler.com/articles/designDead.html)
TUBE - Testable, Understandable, Browsable and
Explainable [3];
Simplicity
The software as a product
Key Points of Good Software Programming
Subsystems and components interfaces are implemented ad-hoc
The Software as a Product
The interface design
The dependency graph
The Software as a Product
Benefits:
●Architectural improvements;
●Dependency graph simplification;
Internal characteristics [2]
•
Maintainability
•
Flexibility
•
Portability
•
Reusability
•
Readability
•
Testability
•
Understandability
The Software as a Product
The Software as a Product
Aspects of a software product
●Market
●Life cycle;
●Value to the business;
[3] Extreme Programming: A gentle introduction (http://www.extremeprogramming.org/rules/simple.html)
[6] Martin Fowler. Is Design Dead? (http://martinfowler.com/articles/designDead.html)
[7] The MDA Guide v1.0.1 - OMG (http://www.omg.org/cgi-bin/doc?omg/03-06-01.pdf)
●Every application must be built to last, to be integrated, to be
updated [7];
●It's easy to refactor [6];
●Helps new people begin contributing quickly [3];
Software Design
The Software as a Product
Complexity
Key Points of Good Software Programming
Catalog interface is based in DAO pattern.
Complexity
[17] http://www.corej2eepatterns.com
Benefits:
●Easy to explain the
implementation;
●DAO Pattern helped to achieve a
robust and stable implementation.
Internal characteristics [2]
•
Maintainability
•
Flexibility
•
Portability
•
Reusability
•
Readability
•
Testability
•
Understandability
Complexity
Kiss - Keep It Simple Stupid using design patterns
[1] Frederick Brooks. The Mythical Man-Month
[[4] Andrew Hunt, David Thomas. Pragmatic Programmer, The: From Journeyman to Master
[14] Fowler, Rice, Foemmel, Hieatt, Mee, Stafford. Patterns of Enterprise Application Architecture
[15] Samisa Abeysinghe. PHP Team Development: Easy and Effective Team Work Using MVC, Agile Development, Source Control, ...
[16] GEORGE J. KLIR. Facets of Systems Science
Complexity
Design Patterns
● Common solutions to recurring problems [4];
● They're rooted in practice [14];
● Learning from experts in the software field [15].
● Conceptual integrity [1].
● Simplifying assumptions, if unavoidable, are introduced carefully [16].
[1] Frederick Brooks. The Mythical Man-Month
[[4] Andrew Hunt, David Thomas. Pragmatic Programmer, The: From Journeyman to Master
[14] Fowler, Rice, Foemmel, Hieatt, Mee, Stafford. Patterns of Enterprise Application Architecture
[15] Samisa Abeysinghe. PHP Team Development: Easy and Effective Team Work Using MVC, Agile Development, Source Control, ...
[16] GEORGE J. KLIR. Facets of Systems Science
Complexity
The code
Key Points of Good Software Programming
DSL to IHM construction domain
Requirements:
1. Easy to define forms and its components (labels, input fields,
buttons);
2. Specify whether the components are enabled or disabled;
3. Map form components to bean properties;
4. Basic input validation according to data type and required
values;
5. Easy to construct master-detail forms;
6. Support to grids and modal windows;
7. Standard behaviors implementation;
Structure:
1. Declarative langague;
2. Fluent interface;
The Code
public class Person
implements Entity {
Long id;
String name;
Gender gender;
List<Kid> children;
<< getters and setters >>
}
public class Kid
implements Entity {
Date birthDate;
String name;
<< getters and setters >>
}
public class MyForm extends AbstractForm <Person> {
public MyForm(String id) {
super(id, Person.class);
// Person data
ihm.enableOn(Operation.New).add("id", "######");
ihm.add("name", 50);
ihm.add("gender", Gender.values());
// Grid of kids
ihm.addGrid("children", Kid.class);
ihm.addColumn("birthDate", "dd-MM-YY hh:mm", true);
ihm.addColumn("name", 30, true);
// Modal to view kid detail
MyKidModal kidModal = ihm.add(new MyKidModal(“kidModal”));
// add the standard behavior
ihm.property("children").addBehavior(ihm.getGrid(), kidModal);
}
}
The Code
Benefits:
● Programming closer to domain;
● Requirement traceable to and from code.
Internal characteristics [2]
•
Maintainability
•
Flexibility
•
Portability
•
Reusability
•
Readability
•
Testability
•
Understandability
The Code
DSL to domain data exchange
Requirements:
1. Simplify the specification of data search criteria;
2. Transparent inter-domain data search;
Structure:
1. Declarative langague;
2. Fluent interface;
The Code
Query<Person> q1 = CatalogBuilder.createQuery(Person.class);
q1.where()
.valueOf(q1.subject().getGender()).matches(Gender.Male)
.valueOf(q1.subject().getName()).matches(“john”);
List<Person> maleJohnResult = q1.getResult();
Query<Person> q2 = CatalogBuilder.createQuery(Person.class);
q2.where()
.valueOf(q2.subject().getGender())
.matches(Gender.Male, Gender.Female, Gender.Female);
List<Person> maleAndFemaleResult = q2.getResult();
The Code
Calendar eighteenYearsAgo = Calendar.getInstance();
eighteenYearsAgo.add(Calendar.YEAR, -18);
Query<Kid> q3 = CatalogBuilder.createQuery(Kid.class);
q3.where()
.valueOf(q3.subject().getBirthDate()).matches(null,
eighteenYearsAgo);
List<Kid> adults = q3.getResult();
Query<Kid> q4 = CatalogBuilder.createQuery(Kid.class);
q4.where(q4.subject().getBirthDate())
.notMatches(Calendar.SATURDAY, Calendar.SUNDAY, Calendar.SUNDAY);
List<Kid> bornOnWorkingDay = q4.getResult();
The Code
Benefits:
Loosely coupled components;
Framework independency;
Reusable mocks.
Internal characteristics [2]
•
Maintainability
•
Flexibility
•
Portability
•
Reusability
•
Readability
•
Testability
•
Understandability
The Code
● Representation is the essence of programming [1]
● Code is really the language in which we ultimately express the requirements [5];
● Program close to the requirements [5];
[1] Frederick Brooks. The Mythical Man-Month
[5] Robert C. Martin. Clean Code. A Handbook of Agile Software Craftsmanship
The power of representation
The Code
● Small;
● Usually declarative;
● Offers expressive power;
● Each user has its own problem domain.
● Expressive power [9], expressivity [10], orthogonality [11], declarative
programming [12], Coding by convention [13].
DSL - Domain-Specific Language [8]
[8] A. van Deursen, P. Klint, J.M.W. Visser. Domain-specific languages
[9] Wikipedia. Programming language (http://en.wikipedia.org/wiki/Programming_language)
[10] Juan José Moreno Navarro. Expressivity of Functional-logic Languages and their Implementation
[11] Wikipedia. Orthogonality (programming) (http://en.wikipedia.org/wiki/Orthogonality_(programming))
[12] Wikipedia. Declarative programming (http://en.wikipedia.org/wiki/Declarative_programming)
The Code
Productivity
Key Points of Good Software Programming
Running the IHM Code Generator
> java -cp IHMCodeGen.jar automation.IHMCodeGen automation.Person id name
gender children:automation.Kid children.name children.birthDate address
// Generated source code
ihm.add("id", "######");
ihm.add("name", 50);
ihm.add("gender", Gender.class);
ihm.addGrid("children", Kid.class);
ihm.addColumn("name", 50);
ihm.addColumn("birthDate", "dd/MM/yyyy");
ihm.add("address", 50);
//
>_
Productivity
Benefits:
●Easy and fast prototyping
●Customer experience anticipation
●Less re-work.
Internal characteristics [2]
•
Maintainability
•
Flexibility
•
Portability
•
Reusability
•
Readability
•
Testability
•
Understandability
Productivity
● People just aren't as repeatable as computers are. Nor should we
expect them to be [4]
● Design also to automate at least some of the construction [7].
[4] Andrew Hunt, David Thomas. Pragmatic Programmer, The: From Journeyman to Master
[7] The MDA Guide v1.0.1 - OMG (http://www.omg.org/cgi-bin/doc?omg/03-06-01.pdf)
Productivity
Productivity
What it means in software?
How to measure?
Efficiency =. Work .
Energy
Work: lines of code, requirements, new features, new
feature - bugs, ...
Energy: time, money, bugs, ...
Productivity
Productivity = . Software .
LOC
Software: a sprint result
LOC: lines of code
Competitive edge
Key Points of Good Software Programming
CRUD Component
The interface design
Assets of code
Competitive Edge
Benefits:
● CRUD Protoypes became fully-
functional and extensible.
● Productivity
Internal characteristics [2]
•
Maintainability
•
Flexibility
•
Portability
•
Reusability
•
Readability
•
Testability
•
Understandability
Competitive Edge
"ninety percent of everything is crud"
Key Points of Good Software Programming
Sturgeon's Revelation
Approximate 41.600 results (0,11 seconds)
Google
Communication
Key Points of Good Software Programming
Communication
The second-system effect [1]
Communication Gap
[1] Frederick Brooks. The Mythical Man-Month
● Software from scratch: no legacy solutions;
● Not enougth time
● Not enougth money
Communication
Collaborative Work Facilities
Effective Communication
● Project , Dojo, Workshops,
● Distributed SCM
● Open Innovation
● Open Source
● Enterprise Social Network
[1] Frederick Brooks. The Mythical Man-Month
[2] Steve McConnell. Code Complete, A Practical Handbook of Software Construction - 2nd Edition
[3] Extreme Programming: A gentle introduction (http://www.extremeprogramming.org/rules/simple.html)
[4] Andrew Hunt, David Thomas. Pragmatic Programmer, The: From Journeyman to Master
[5] Robert C. Martin. Clean Code. A Handbook of Agile Software Craftsmanship
[6] Martin Fowler. Is Design Dead? (http://martinfowler.com/articles/designDead.html)
[7] The MDA Guide v1.0.1 - OMG (http://www.omg.org/cgi-bin/doc?omg/03-06-01.pdf)
[8] A. van Deursen, P. Klint, J.M.W. Visser. Domain-specific languages
[9] Wikipedia. Programming language (http://en.wikipedia.org/wiki/Programming_language)
[10] Juan José Moreno Navarro. Expressivity of Functional-logic Languages and their Implementation
[11] Wikipedia. Orthogonality (programming) (http://en.wikipedia.org/wiki/Orthogonality_(programming))
References
[12] Wikipedia. Declarative programming (http://en.wikipedia.org/wiki/Declarative_programming)
[13] Wikipedia. Convention over configuration (http://en.wikipedia.org/wiki/Convention_over_configuration)
[14] Fowler, Rice, Foemmel, Hieatt, Mee, Stafford. Patterns of Enterprise Application Architecture
[15] Samisa Abeysinghe. PHP Team Development: Easy and Effective Team Work Using MVC, AgileDevelopment, Source
Control, Testing, Bug Tracking, and More
[16] GEORGE J. KLIR. Facets of Systems Science
References
To God
To my wife
To Bruna, Cesar, Eder and Ricardo
To my co-workers
Thanks
Key points of good software programming

Key points of good software programming

  • 1.
    Key Points ofGood Software Programming A Practical Approach São Paulo, Brazil, January 2014
  • 2.
    Márcio Luís daSilva Senior Software Developer at 7COMm, Brazil Information Systems Bachelor Degree Centro Universitário Fundação Santo André The author This Presentation silva.luis.marcio@gmail.com About Software developers. The audience Is about refactoring, polymorfism, design patterns, programming languages, automated code generation, componentization and reuse. All initiatives were implemented in real life. Except for the automated code generation tool, All implementations were used at the moment they were collected.
  • 3.
    Key Points ofGood Software Programming ● Software Objective ● Refactoring ● Polymorfism ● Design Patterns ● Computer Programming ● Automate Code Generation ● Componentization & Reuse ● Best Practices in Software Content
  • 4.
    ● Good Software ●Simplicity ● The Software as a Product ● Complexity Key Points of Good Software Programming Road Map ● The code ● Productivity ● Competitive Edge ● Communication
  • 5.
    The good software KeyPoints of Good Software Programming
  • 6.
    External characteristics [2] ●Correctness ● Usability ● Efficiency ● Reliability ● Integrity ● Adaptability ● Accuracy ● Robustness [2] Steve McConnell. Code Complete, A Practical Handbook of Software Construction Internal characteristics [2] • Maintainability • Flexibility • Portability • Reusability • Readability • Testability • Understandability Profitable Customers Suppliers Good experience The Good Software +
  • 7.
    Many programming projectsare still operated like machine shops. [1] Frederick Brooks. The Mythical Man-Month • Common development and maintenance of the general-purpose programming tools. • High-level language; • Sharing and protection for data and programs, extensive library management; • facilities for cooperative work The essential problem is communication. Successful Improvements The Technological Scenario
  • 8.
    Key Points ofGood Software Programming Simplicity
  • 9.
    1 public MyEntitysave(final MyEntity entity) { 2 validator.assertValid(entity); 3 4 // Decide to update or insert 5 if (entity.getVersion() != null) { 6 // find by the business id 7 MyEntity persistedEntity = findByName(entity.getName()); 8 9 /** 10 * Check if exists. 11 */ 12 if (persistedEntity == null) { 13 throw new ConcurrencyException(entity); 14 } 15 16 if (!persistedEntity.getVersion().equals(entity.getVersion())) { 17 throw new ConcurrencyException(entity); 18 } 19 20 MyEntity updatedEntity = dataManager.merge(entity); 21 22 dataManager.flush();// Force flush to capture potential exceptions 23 dataManager.evict(updatedEntity); 24 25 return updatedEntity; 26 } else { 27 // find by the business id 28 final MyEntity persistedEntity = findByName(entity.getName()); 29 30 /** 31 * Check if exists. 32 */ 33 33 if (persistedEntity != null) { 34 throw new ConcurrencyException(persistedEntity); 35 } 36 37 try { 38 39 dataManager.persist(entity); 30 dataManager.flush();// Force flush to capture potential 41 42 } catch (final DataIntegrityViolationException e) { 43 throw new ConcurrencyException(entity); 44 } 45 46 dataManager.evict(entity); 47 48 return entity; 49 } 50} 25 occurrencies found Simplicity
  • 10.
    1 public Tpersist(T object) throws PersistenceException { 2 3 if (checkUpdate(object) != null) { 4 5 getHibernateOperations().saveOrUpdate(object); 6 return object; 7 8 } else { 9 10 checkUnique(object); 11 getHibernateOperations().persist(object); 12 return object; 13 14 } 15 } 16 17 private T checkUpdate(T object) throws PersistenceException { 18 Serializable id = JPAUtils.getId(object); 19 Object version = JPAUtils.getVersion(object); 20 21 T persistedObj = null; 22 23 if (id != null) { 24 25 persistedObj = getHibernateOperations().get((Class<T>) this.entityType, id); 26 if (persistedObj == null) { 27 throw new ConcurrencyException(getFailedEntity(object)); 28 } 29 getHibernateOperations().evict(persistedObj); 30 31 } 32 33 if (version != null && persistedObj != null) { 34 35 Object persistedVersion = JPAUtils.getVersion(persistedObj); 36 if (!persistedVersion.equals(version)) { 37 throw new ConcurrencyException(getFailedEntity(object)); 38 } 39 } 40 41 return persistedObj; 42 } 43 44 private T checkUnique(T object) throws PersistenceException { 45 String[] propertyNames = JPAUtils.getUniqueProperties(object.getClass()); 46 if (propertyNames.length > 0) { 47 Object[] propertyValues = JPAUtils.getUniqueValues(object); 48 DetachedCriteria criteria = DetachedCriteria.forClass(object.getClass()); 49 for (int index = 0; index < propertyNames.length; index++) { 50 criteria.add(Restrictions.eq(propertyNames[index], propertyValues[index])); 51 } 52 if (!hibernateOperations.findByCriteria(criteria).isEmpty()) { 53 throw new ConcurrencyException(getFailedEntity(object)); 54 } 55 } 56 return object; 57 } The DRY implementation Simplicity
  • 11.
    Benefits: ● Less codeto correct defects; ● Less code to change; ● Less code to test. Internal characteristics [2] • Maintainability • Flexibility • Portability • Reusability • Readability • Testability • Understandability Simplicity
  • 12.
    ●Once and onlyonce [3]; ●DRY - Don't Repeat Yourself [4]; ●Duplication represents additional work, risk, and unnecessary complexity [5]. ●The focus on eliminating duplication can take us a long way in the direction of simplicity [6]. [3] Extreme Programming: A gentle introduction (http://www.extremeprogramming.org/rules/simple.html) [4] Andrew Hunt, David Thomas. Pragmatic Programmer, The: From Journeyman to Master [5] Robert C. Martin. Clean Code. A Handbook of Agile Software Craftsmanship [6] Martin Fowler. Is Design Dead? (http://martinfowler.com/articles/designDead.html) TUBE - Testable, Understandable, Browsable and Explainable [3]; Simplicity
  • 13.
    The software asa product Key Points of Good Software Programming
  • 14.
    Subsystems and componentsinterfaces are implemented ad-hoc The Software as a Product
  • 15.
    The interface design Thedependency graph The Software as a Product
  • 16.
    Benefits: ●Architectural improvements; ●Dependency graphsimplification; Internal characteristics [2] • Maintainability • Flexibility • Portability • Reusability • Readability • Testability • Understandability The Software as a Product
  • 17.
    The Software asa Product Aspects of a software product ●Market ●Life cycle; ●Value to the business;
  • 18.
    [3] Extreme Programming:A gentle introduction (http://www.extremeprogramming.org/rules/simple.html) [6] Martin Fowler. Is Design Dead? (http://martinfowler.com/articles/designDead.html) [7] The MDA Guide v1.0.1 - OMG (http://www.omg.org/cgi-bin/doc?omg/03-06-01.pdf) ●Every application must be built to last, to be integrated, to be updated [7]; ●It's easy to refactor [6]; ●Helps new people begin contributing quickly [3]; Software Design The Software as a Product
  • 19.
    Complexity Key Points ofGood Software Programming
  • 20.
    Catalog interface isbased in DAO pattern. Complexity [17] http://www.corej2eepatterns.com
  • 21.
    Benefits: ●Easy to explainthe implementation; ●DAO Pattern helped to achieve a robust and stable implementation. Internal characteristics [2] • Maintainability • Flexibility • Portability • Reusability • Readability • Testability • Understandability Complexity
  • 22.
    Kiss - KeepIt Simple Stupid using design patterns [1] Frederick Brooks. The Mythical Man-Month [[4] Andrew Hunt, David Thomas. Pragmatic Programmer, The: From Journeyman to Master [14] Fowler, Rice, Foemmel, Hieatt, Mee, Stafford. Patterns of Enterprise Application Architecture [15] Samisa Abeysinghe. PHP Team Development: Easy and Effective Team Work Using MVC, Agile Development, Source Control, ... [16] GEORGE J. KLIR. Facets of Systems Science Complexity
  • 23.
    Design Patterns ● Commonsolutions to recurring problems [4]; ● They're rooted in practice [14]; ● Learning from experts in the software field [15]. ● Conceptual integrity [1]. ● Simplifying assumptions, if unavoidable, are introduced carefully [16]. [1] Frederick Brooks. The Mythical Man-Month [[4] Andrew Hunt, David Thomas. Pragmatic Programmer, The: From Journeyman to Master [14] Fowler, Rice, Foemmel, Hieatt, Mee, Stafford. Patterns of Enterprise Application Architecture [15] Samisa Abeysinghe. PHP Team Development: Easy and Effective Team Work Using MVC, Agile Development, Source Control, ... [16] GEORGE J. KLIR. Facets of Systems Science Complexity
  • 24.
    The code Key Pointsof Good Software Programming
  • 25.
    DSL to IHMconstruction domain Requirements: 1. Easy to define forms and its components (labels, input fields, buttons); 2. Specify whether the components are enabled or disabled; 3. Map form components to bean properties; 4. Basic input validation according to data type and required values; 5. Easy to construct master-detail forms; 6. Support to grids and modal windows; 7. Standard behaviors implementation; Structure: 1. Declarative langague; 2. Fluent interface; The Code
  • 26.
    public class Person implementsEntity { Long id; String name; Gender gender; List<Kid> children; << getters and setters >> } public class Kid implements Entity { Date birthDate; String name; << getters and setters >> } public class MyForm extends AbstractForm <Person> { public MyForm(String id) { super(id, Person.class); // Person data ihm.enableOn(Operation.New).add("id", "######"); ihm.add("name", 50); ihm.add("gender", Gender.values()); // Grid of kids ihm.addGrid("children", Kid.class); ihm.addColumn("birthDate", "dd-MM-YY hh:mm", true); ihm.addColumn("name", 30, true); // Modal to view kid detail MyKidModal kidModal = ihm.add(new MyKidModal(“kidModal”)); // add the standard behavior ihm.property("children").addBehavior(ihm.getGrid(), kidModal); } } The Code
  • 27.
    Benefits: ● Programming closerto domain; ● Requirement traceable to and from code. Internal characteristics [2] • Maintainability • Flexibility • Portability • Reusability • Readability • Testability • Understandability The Code
  • 28.
    DSL to domaindata exchange Requirements: 1. Simplify the specification of data search criteria; 2. Transparent inter-domain data search; Structure: 1. Declarative langague; 2. Fluent interface; The Code
  • 29.
    Query<Person> q1 =CatalogBuilder.createQuery(Person.class); q1.where() .valueOf(q1.subject().getGender()).matches(Gender.Male) .valueOf(q1.subject().getName()).matches(“john”); List<Person> maleJohnResult = q1.getResult(); Query<Person> q2 = CatalogBuilder.createQuery(Person.class); q2.where() .valueOf(q2.subject().getGender()) .matches(Gender.Male, Gender.Female, Gender.Female); List<Person> maleAndFemaleResult = q2.getResult(); The Code
  • 30.
    Calendar eighteenYearsAgo =Calendar.getInstance(); eighteenYearsAgo.add(Calendar.YEAR, -18); Query<Kid> q3 = CatalogBuilder.createQuery(Kid.class); q3.where() .valueOf(q3.subject().getBirthDate()).matches(null, eighteenYearsAgo); List<Kid> adults = q3.getResult(); Query<Kid> q4 = CatalogBuilder.createQuery(Kid.class); q4.where(q4.subject().getBirthDate()) .notMatches(Calendar.SATURDAY, Calendar.SUNDAY, Calendar.SUNDAY); List<Kid> bornOnWorkingDay = q4.getResult(); The Code
  • 31.
    Benefits: Loosely coupled components; Frameworkindependency; Reusable mocks. Internal characteristics [2] • Maintainability • Flexibility • Portability • Reusability • Readability • Testability • Understandability The Code
  • 32.
    ● Representation isthe essence of programming [1] ● Code is really the language in which we ultimately express the requirements [5]; ● Program close to the requirements [5]; [1] Frederick Brooks. The Mythical Man-Month [5] Robert C. Martin. Clean Code. A Handbook of Agile Software Craftsmanship The power of representation The Code
  • 33.
    ● Small; ● Usuallydeclarative; ● Offers expressive power; ● Each user has its own problem domain. ● Expressive power [9], expressivity [10], orthogonality [11], declarative programming [12], Coding by convention [13]. DSL - Domain-Specific Language [8] [8] A. van Deursen, P. Klint, J.M.W. Visser. Domain-specific languages [9] Wikipedia. Programming language (http://en.wikipedia.org/wiki/Programming_language) [10] Juan José Moreno Navarro. Expressivity of Functional-logic Languages and their Implementation [11] Wikipedia. Orthogonality (programming) (http://en.wikipedia.org/wiki/Orthogonality_(programming)) [12] Wikipedia. Declarative programming (http://en.wikipedia.org/wiki/Declarative_programming) The Code
  • 34.
    Productivity Key Points ofGood Software Programming
  • 35.
    Running the IHMCode Generator > java -cp IHMCodeGen.jar automation.IHMCodeGen automation.Person id name gender children:automation.Kid children.name children.birthDate address // Generated source code ihm.add("id", "######"); ihm.add("name", 50); ihm.add("gender", Gender.class); ihm.addGrid("children", Kid.class); ihm.addColumn("name", 50); ihm.addColumn("birthDate", "dd/MM/yyyy"); ihm.add("address", 50); // >_ Productivity
  • 36.
    Benefits: ●Easy and fastprototyping ●Customer experience anticipation ●Less re-work. Internal characteristics [2] • Maintainability • Flexibility • Portability • Reusability • Readability • Testability • Understandability Productivity
  • 37.
    ● People justaren't as repeatable as computers are. Nor should we expect them to be [4] ● Design also to automate at least some of the construction [7]. [4] Andrew Hunt, David Thomas. Pragmatic Programmer, The: From Journeyman to Master [7] The MDA Guide v1.0.1 - OMG (http://www.omg.org/cgi-bin/doc?omg/03-06-01.pdf) Productivity
  • 38.
    Productivity What it meansin software? How to measure? Efficiency =. Work . Energy Work: lines of code, requirements, new features, new feature - bugs, ... Energy: time, money, bugs, ...
  • 39.
    Productivity Productivity = .Software . LOC Software: a sprint result LOC: lines of code
  • 40.
    Competitive edge Key Pointsof Good Software Programming
  • 41.
    CRUD Component The interfacedesign Assets of code Competitive Edge
  • 42.
    Benefits: ● CRUD Protoypesbecame fully- functional and extensible. ● Productivity Internal characteristics [2] • Maintainability • Flexibility • Portability • Reusability • Readability • Testability • Understandability Competitive Edge
  • 43.
    "ninety percent ofeverything is crud" Key Points of Good Software Programming Sturgeon's Revelation Approximate 41.600 results (0,11 seconds) Google
  • 44.
    Communication Key Points ofGood Software Programming
  • 45.
    Communication The second-system effect[1] Communication Gap [1] Frederick Brooks. The Mythical Man-Month ● Software from scratch: no legacy solutions; ● Not enougth time ● Not enougth money
  • 46.
    Communication Collaborative Work Facilities EffectiveCommunication ● Project , Dojo, Workshops, ● Distributed SCM ● Open Innovation ● Open Source ● Enterprise Social Network
  • 47.
    [1] Frederick Brooks.The Mythical Man-Month [2] Steve McConnell. Code Complete, A Practical Handbook of Software Construction - 2nd Edition [3] Extreme Programming: A gentle introduction (http://www.extremeprogramming.org/rules/simple.html) [4] Andrew Hunt, David Thomas. Pragmatic Programmer, The: From Journeyman to Master [5] Robert C. Martin. Clean Code. A Handbook of Agile Software Craftsmanship [6] Martin Fowler. Is Design Dead? (http://martinfowler.com/articles/designDead.html) [7] The MDA Guide v1.0.1 - OMG (http://www.omg.org/cgi-bin/doc?omg/03-06-01.pdf) [8] A. van Deursen, P. Klint, J.M.W. Visser. Domain-specific languages [9] Wikipedia. Programming language (http://en.wikipedia.org/wiki/Programming_language) [10] Juan José Moreno Navarro. Expressivity of Functional-logic Languages and their Implementation [11] Wikipedia. Orthogonality (programming) (http://en.wikipedia.org/wiki/Orthogonality_(programming)) References
  • 48.
    [12] Wikipedia. Declarativeprogramming (http://en.wikipedia.org/wiki/Declarative_programming) [13] Wikipedia. Convention over configuration (http://en.wikipedia.org/wiki/Convention_over_configuration) [14] Fowler, Rice, Foemmel, Hieatt, Mee, Stafford. Patterns of Enterprise Application Architecture [15] Samisa Abeysinghe. PHP Team Development: Easy and Effective Team Work Using MVC, AgileDevelopment, Source Control, Testing, Bug Tracking, and More [16] GEORGE J. KLIR. Facets of Systems Science References
  • 49.
    To God To mywife To Bruna, Cesar, Eder and Ricardo To my co-workers Thanks