Most developers write code to fulfil a business requirement, however the cost of project is not decided by the development but by the effort maintenance. So the emphasis should be to write quality , clean code that minimizes time spent on maintenance.
2015.01.09 - Writing Modern Applications for Mobile and WebMarco Parenzan
Traditional programming is quite old (60+ years)
Object Oriented Programming is not so old, but old enough (35+ years)
We can say that OOP is able to satisfy our needs of Modern programming
Modern is not about modern programming principles and paradigms
Modern is about current scenarios in which our programming abilities have to be spent these days
Just 10 years ago (in 2K years) we were focusing on something else
Modern Programming for about modern programming challenges:
- Cloud
- Big Data
- Mobile and Devices
- Internet of Things
Principles
- Application Lifecycle Management
- Scrum
- Maintainable Code
Imperative Modeling
- Don’t tell what you want to do: just do it!
Responsibility Modeling
- Why are you coding? Which is the intention inside every line you write?
Functional Modeling
- Declare what you need! I’ll implement it!
Object Modeling
- Classes are the way to describe model into a domain
Contract Modeling
- Class is not just encapsulation. It’s also declaration of a contract
Interface Modeling
- Class should be implementation only. Interfaces are a better way to describe a contract
Three tier Modeling
- An Architectural model for an application
“Blueprints” Modeling
- Feel free to express yourself…or not? Please refer to some work done by experts!
“No more One” Modeling
- One model DOES NOT FITS for all. Multiple models are needed to single aspects of an application
This is a presentation I did for the new interns at Duo Software which I highlight the pros and cons of being creative and following widely used best practices in software development
How to develop high quality software? What are the key/fundamental principles for software design? What is the relationship between principles, bad smells, design patterns, and refactoring? This presentation answers all this and more. Don't miss it!
2015.01.09 - Writing Modern Applications for Mobile and WebMarco Parenzan
Traditional programming is quite old (60+ years)
Object Oriented Programming is not so old, but old enough (35+ years)
We can say that OOP is able to satisfy our needs of Modern programming
Modern is not about modern programming principles and paradigms
Modern is about current scenarios in which our programming abilities have to be spent these days
Just 10 years ago (in 2K years) we were focusing on something else
Modern Programming for about modern programming challenges:
- Cloud
- Big Data
- Mobile and Devices
- Internet of Things
Principles
- Application Lifecycle Management
- Scrum
- Maintainable Code
Imperative Modeling
- Don’t tell what you want to do: just do it!
Responsibility Modeling
- Why are you coding? Which is the intention inside every line you write?
Functional Modeling
- Declare what you need! I’ll implement it!
Object Modeling
- Classes are the way to describe model into a domain
Contract Modeling
- Class is not just encapsulation. It’s also declaration of a contract
Interface Modeling
- Class should be implementation only. Interfaces are a better way to describe a contract
Three tier Modeling
- An Architectural model for an application
“Blueprints” Modeling
- Feel free to express yourself…or not? Please refer to some work done by experts!
“No more One” Modeling
- One model DOES NOT FITS for all. Multiple models are needed to single aspects of an application
This is a presentation I did for the new interns at Duo Software which I highlight the pros and cons of being creative and following widely used best practices in software development
How to develop high quality software? What are the key/fundamental principles for software design? What is the relationship between principles, bad smells, design patterns, and refactoring? This presentation answers all this and more. Don't miss it!
Do you already know what big ball of mud means?
And code smell?, Is your nose prepared to detect them?
Can you affirm that you are commited with the mantainability?
Do you have architectural sensibility to avoid these kind of situations? Or you are comfortable with the inertia of the day-to-day task of patching the holes. (it doesn't matter if it works..)
While much attention has been focused on high-level software architectural patterns, what is, in effect, the de-facto standard software architecture is seldom discussed.
This talk is intended to identify and summarize the causes that lead to misusing our time on complex maintenance, and give tips and best practices to avoid the big ball of mud and to achieve the best quality products.
It took me about one and a half year to update my cheat sheet about clean code and TDD.
But now, it’s here.
The cheat sheet has grown quite a bit and now contains principles, patterns, smells and guidelines for
clean code
class and package design
TDD – Test Driven Development
ATDD – Acceptance Test Driven Development
Continuous Integration
I had to re-layout the sheets because maintenance became a nightmare (yes, very ironic).
Reference: http://www.planetgeek.ch/2013/06/05/clean-code-cheat-sheet/
A complexity approach to managing technology enabled business transformation ...Mikkel Brahm
An alternative - or rather a supplement - to using systems theory to understand organizations and organizational change by drawing on Complex Responsive Processes of Relating.
Pragmatic Not Dogmatic TDD Agile2012 by Joseph Yoder and Rebecca Wirfs-BrockJoseph Yoder
This presentation challenges the "norm" for TDD. Testing should be an integral part of your daily programming practice. But you don’t always need to derive your code via many test-code-revise-retest cycles to be test-driven. Some find it more natural to outline a related set of tests first, and use those test scenarios to guide them as they write code. Once they’ve completed a “good enough” implementation that supports the test scenarios, they then write those tests and incrementally fix any bugs as they go. As long as you don’t write hundreds of lines of code without any testing, there isn’t a single best way to be Test Driven. There’s a lot to becoming proficient at TDD. Developing automated test suites, refactoring and reworking tests to eliminate duplication, and testing for exceptional conditions, are just a few. Additionally, acceptance tests, smoke tests, integration, performance and load tests support incremental development as well. If all this testing sounds like too much work, well…let’s be practical. Testing shouldn’t be done just for testing’s sake. Instead, the tests you write should give you leverage to confidently change and evolve your code base and validate the requirements of the system. That’s why it is important to know what to test, what not to test, and when to stop testing.
TDD vs. ATDD - What, Why, Which, When & WhereDaniel Davis
This is a slide deck for a discussion about Test Driven Development (TDD) and Acceptance Test Driven Development (ATDD) and starting to explore the differences between them. Get some insight into why we use them and the advantages and disadvantages of both, as well as, get a better understanding of which should be used where and when. By the end of the session you should be well along the path to TDD vs. ATDD enlightenment.
An introduction to Acceptance Test Driven Development (ATDD). We discuss the benefits and the best way to let test creation drive your development efforts, giving the teams the best chance to deliver what you need.
PATTERNS01 - An Introduction to Design PatternsMichael Heron
An introduction to design patterns in object orientation. Suitable for intermediate to advanced computing students and those studying software engineering.
There are many design principles that have become best practices over the years. Using these principles we can develop scalable and maintainable enterprise application with time tested approaches.
This course provides a detailed introduction to the Object Oriented techniques identified by Robert Martin as the SOLID principles of software design. Intended for both novice and intermediary developers, each of the five principles are fully defined and explored. Real-world coding examples are provided for each software tenant to help fully expound upon the design techniques. By the end of the session, developers will be able to identify common code smells while applying SOLID programming practices that ensure clean and maintainable code.
Refactoring page objects The Screenplay Pattern RiverGlide
As seen at BDD Exchange 2016 and Selenium Conf 2016
The Screenplay Pattern, first created by Antony Marcano, is an alternative model to PageObjects. Today, it is growing in popularity with increasing tool support in popular testing frameworks.
PageObjects provide an easy-to-follow, simple structure that avoids early maintenance issues. They were introduced to help test-developers avoid mistaking flaky tests for problems with Selenium. But, PageObjects break some key OO design rules, making maintenance more difficult over time. They are a useful first step, but why do we stop there?
In this session you’ll learn about the SOLID design principles that PageObjects disregard. You’ll see why this leads to problems. You’ll see how and why PageObjects benefit from refactoring to SOLID design principles. Finally, you’ll meet the Screenplay Pattern – an alternative model based on SOLID principles that saves you the trouble.
Do you already know what big ball of mud means?
And code smell?, Is your nose prepared to detect them?
Can you affirm that you are commited with the mantainability?
Do you have architectural sensibility to avoid these kind of situations? Or you are comfortable with the inertia of the day-to-day task of patching the holes. (it doesn't matter if it works..)
While much attention has been focused on high-level software architectural patterns, what is, in effect, the de-facto standard software architecture is seldom discussed.
This talk is intended to identify and summarize the causes that lead to misusing our time on complex maintenance, and give tips and best practices to avoid the big ball of mud and to achieve the best quality products.
It took me about one and a half year to update my cheat sheet about clean code and TDD.
But now, it’s here.
The cheat sheet has grown quite a bit and now contains principles, patterns, smells and guidelines for
clean code
class and package design
TDD – Test Driven Development
ATDD – Acceptance Test Driven Development
Continuous Integration
I had to re-layout the sheets because maintenance became a nightmare (yes, very ironic).
Reference: http://www.planetgeek.ch/2013/06/05/clean-code-cheat-sheet/
A complexity approach to managing technology enabled business transformation ...Mikkel Brahm
An alternative - or rather a supplement - to using systems theory to understand organizations and organizational change by drawing on Complex Responsive Processes of Relating.
Pragmatic Not Dogmatic TDD Agile2012 by Joseph Yoder and Rebecca Wirfs-BrockJoseph Yoder
This presentation challenges the "norm" for TDD. Testing should be an integral part of your daily programming practice. But you don’t always need to derive your code via many test-code-revise-retest cycles to be test-driven. Some find it more natural to outline a related set of tests first, and use those test scenarios to guide them as they write code. Once they’ve completed a “good enough” implementation that supports the test scenarios, they then write those tests and incrementally fix any bugs as they go. As long as you don’t write hundreds of lines of code without any testing, there isn’t a single best way to be Test Driven. There’s a lot to becoming proficient at TDD. Developing automated test suites, refactoring and reworking tests to eliminate duplication, and testing for exceptional conditions, are just a few. Additionally, acceptance tests, smoke tests, integration, performance and load tests support incremental development as well. If all this testing sounds like too much work, well…let’s be practical. Testing shouldn’t be done just for testing’s sake. Instead, the tests you write should give you leverage to confidently change and evolve your code base and validate the requirements of the system. That’s why it is important to know what to test, what not to test, and when to stop testing.
TDD vs. ATDD - What, Why, Which, When & WhereDaniel Davis
This is a slide deck for a discussion about Test Driven Development (TDD) and Acceptance Test Driven Development (ATDD) and starting to explore the differences between them. Get some insight into why we use them and the advantages and disadvantages of both, as well as, get a better understanding of which should be used where and when. By the end of the session you should be well along the path to TDD vs. ATDD enlightenment.
An introduction to Acceptance Test Driven Development (ATDD). We discuss the benefits and the best way to let test creation drive your development efforts, giving the teams the best chance to deliver what you need.
PATTERNS01 - An Introduction to Design PatternsMichael Heron
An introduction to design patterns in object orientation. Suitable for intermediate to advanced computing students and those studying software engineering.
There are many design principles that have become best practices over the years. Using these principles we can develop scalable and maintainable enterprise application with time tested approaches.
This course provides a detailed introduction to the Object Oriented techniques identified by Robert Martin as the SOLID principles of software design. Intended for both novice and intermediary developers, each of the five principles are fully defined and explored. Real-world coding examples are provided for each software tenant to help fully expound upon the design techniques. By the end of the session, developers will be able to identify common code smells while applying SOLID programming practices that ensure clean and maintainable code.
Refactoring page objects The Screenplay Pattern RiverGlide
As seen at BDD Exchange 2016 and Selenium Conf 2016
The Screenplay Pattern, first created by Antony Marcano, is an alternative model to PageObjects. Today, it is growing in popularity with increasing tool support in popular testing frameworks.
PageObjects provide an easy-to-follow, simple structure that avoids early maintenance issues. They were introduced to help test-developers avoid mistaking flaky tests for problems with Selenium. But, PageObjects break some key OO design rules, making maintenance more difficult over time. They are a useful first step, but why do we stop there?
In this session you’ll learn about the SOLID design principles that PageObjects disregard. You’ll see why this leads to problems. You’ll see how and why PageObjects benefit from refactoring to SOLID design principles. Finally, you’ll meet the Screenplay Pattern – an alternative model based on SOLID principles that saves you the trouble.
Design Patterns Explained: From Analysis through ImplementationTechWell
Alan Shalloway takes you beyond thinking of design patterns as “solutions to a problem in a context.” Patterns are really about handling variations in your problem domain while keeping code from becoming complex and difficult to maintain as the system evolves. Alan begins by describing the classic use of patterns. He shows how design patterns implement good coding practices and then explains key design patterns including Strategy, Bridge, Adapter, Façade, and Abstract Factory. In small group exercises, learn how to use patterns to create robust architectures that can readily adapt as new requirements arise. Lessons from these patterns are used to illustrate how to do domain analysis based on abstracting out commonalities in a problem domain and identifying particular variations that must be implemented. Leave with a working understanding of what design patterns are and a better way to build models of your application domains.
Following on from the success of last year, this annual event for London's architect community will have architectural innovation as a theme this year, and particularly CQRS. At the DDD eXchange we will feature leading thinkers and architects who will share their experience and Eric Evans is the programme lead.
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...Abdelkrim Boujraf
In summary, we have presented here a method for efficiently testing large parts of web-based software by using elements of code generation to generate automatable tests, and by using BDD concepts to model tests for non-generated screens and non-generated business actions. Further, we have described a method for context-based unit
testing that, when combined with generated code and tests, yields an acceptable trade-off between development efficiency and time spent on testing
This is presentation I did to showcase our new platform and architecture. The completion of the platform is an ongoing set of projects. We are planning to convert some of our projects which we used for the platform as Open Source projects.
This is presentation done by me to showcase our new microservice platform with CI-CD pipe-lining. We are still adding the microservices and this will continue. We are planning to open source some of the projects we built had to extend in the near future.
How ICT is shaping Travel and Tourism landscapesindikaMaligaspe
A presentation on how ICT has changed Travel and Tourism Landscape. The main areas of focus is Distribution, Marketing , User Experience and Retail of travel products.
Designing Rest Services - An Architects GuideindikaMaligaspe
This presentation done on REST services explains the fundamentals of REST services as well as emphasizes on several best practices and standards that we have learnt over the years in building our REST API's.
A simple way to develop in java with performance in mind. In this presentation we will look at some of the basics that we tend to miss when developing, which eventually leads to memory inefficiencies in our applications.
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
top nidhi software solution freedownloadvrstrong314
This presentation emphasizes the importance of data security and legal compliance for Nidhi companies in India. It highlights how online Nidhi software solutions, like Vector Nidhi Software, offer advanced features tailored to these needs. Key aspects include encryption, access controls, and audit trails to ensure data security. The software complies with regulatory guidelines from the MCA and RBI and adheres to Nidhi Rules, 2014. With customizable, user-friendly interfaces and real-time features, these Nidhi software solutions enhance efficiency, support growth, and provide exceptional member services. The presentation concludes with contact information for further inquiries.
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfJay Das
With the advent of artificial intelligence or AI tools, project management processes are undergoing a transformative shift. By using tools like ChatGPT, and Bard organizations can empower their leaders and managers to plan, execute, and monitor projects more effectively.
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Writing Quality Code
1. “Writing Quality Code”
By Indika Maligaspe
““Give a man a fish and you feed him for a dayGive a man a fish and you feed him for a day
Teach him how to fish and you feed him for a lifetime”Teach him how to fish and you feed him for a lifetime”
2. Intro...Intro...
Indika Maligaspe
K. Indika Maligaspe
Developer, Designer, Architect , Trainer
Tech Geek specialized in JAVA and .Net
Over 14 years if experience in IT / Web Technologies
Lover of almost all sports...
http://www.linkedin.com/profile/view?id=201732082&trk=nav_responsive_tab_profile
4. Seminar AgendaSeminar Agenda
What effects Software Quality?
How to accommodate change?
What are Code Qualities?
Principles vs. Practices
Principles of Coding (Rules of Thumb)
Organizing Principles
Clarity Principles (good practices)
Summary
Q&A
5. What effects Software Quality?What effects Software Quality?
Two questions…..Two questions…..
• How many of you have been involvedHow many of you have been involved
inin
A totally successful project?
A totally failed project?
A "challenged" project?
6. What effects Software Quality?What effects Software Quality?
Two questions…..Two questions…..
• When Adding FunctionalityWhen Adding Functionality
Where was the Problem?Where was the Problem?
Is it writing the new code?
Is it integrating it into the system?
Why?
7. How can we design toHow can we design to
accommodate change?accommodate change?
We are not trying to anticipate change, per se, as much
as writing our code to accommodate change better.
Trying to anticipate change can lead to “paralysis by
analysis”
To do this we need
A way to avoid change when possible (outside of the scope of this
document)
Componentized Architectures (CBA / SBC etc…)
Use of Design Patterns
Agile concepts
A way to make change less risky when one cannot avoid it
Code clarity and maintainability
Refactoring
8. What are Code Qualities?What are Code Qualities?
• A computer has no concept of "well-
written“ source code. However, from a
human point of view source code can be
written in a way that has an effect on the
effort needed to comprehend its
behavior.
• Many source code programming style
guides, which often stress readability
and usually language-specific
conventions are aimed at reducing the
cost of source code maintenance by
having code predictability.
9. PredictabilityPredictability
We can’t predict how our requirements are
going to change
However we can predict how our code will
adapt to unpredictable requirement
changes
How can we increase our predictive
abilities?
Pay attention to code quality
10. Six Code QualitiesSix Code Qualities
Cohesive
Correct Coupling
Non Redundant
Encapsulated
Testable
Assertive
11. Principles vs. PracticesPrinciples vs. Practices
Principle
A standard
Theory
Practice
How you put a principle to practice
i.e.
Principle - The need to be clean
Practice - Wash hands
12. CohesionCohesion
Cohesion refers to how “closely the
operations in a routine [or class] are
related ” (Code complete – Steve McConnell)
Strong cohesion is related to clarity and
understanding.
No "schizophrenic classes”
No “10000 - line classes”
No “10 page methods"‐
13. Good StrongGood Strong cohesioncohesion
Class Cohesion - A class has a single
responsibility, and everything in the class is about
fulfilling that responsibility.
Using design patterns and OO concepts (strategy / encapsulation /
open – close etc…)
Method Cohesion - Each method is about
fulfilling one functional aspect of the classes
responsibility.
Programming by intention can help us to code with better method
cohesion from the beginning
14. Class Cohesion - exampleClass Cohesion - example
Class cohesion will be covered in detail in future sessions
17. What “programming by intention”What “programming by intention”
will bringwill bring
Method cohesion
Cohesion of perspective
Sergeant is the controller (very little
implementation)
Private’s do the work (implementation)
Ease of refactoring
Ease of applying/forming design patterns
Easier to test
18. CouplingCoupling
Coupling refers “to the strength of a connection between two
routines [or classes] Coupling is complement to cohesion. Cohesion
describes how strongly the internal contents of a routine [or class]
are related to each other. Coupling describes how strongly a routine
is related to other routines. The goal is to create routines [and
classes] with internal integrity (strong cohesion) and small, direct,
visible, and flexible relations to other routines [and classes] (loose
coupling).”*
Tight coupling is related to highly interconnected code
* Code Complete Steve McConnell 1993 p 22 Copyright
19. Correct CouplingCorrect Coupling
How interconnected Objects are
Loosely coupled – Objects should be independent
and should mind their own business.
One employee should not know about salary details
of other employees in the company
Tight coupled – Objects are interconnected and
intertwined. Change one place and “All hell breaks
loose”
Every employee knows the salaries of all the
employees in the company. Give increment to one –
MAJOR PROBLEM
21. Types of couplingTypes of coupling
Identity
One type to the fact that coupled another type exists.
Representational
One type coupled to the interface of another.
Inheritance
Subtypes are coupled to their superclass, in that any change in
the superclass will propagate downward.
Subclass
One type coupled to the fact that there are subclasses to a type,
and what specific subclasses exist.
Writing Quality code David Bernstein – 2008 p24 Copyright
22. No Redundancy –No Redundancy –
Avoiding duplicationAvoiding duplication
"One Rule in One Place"
Redundancy is not just:
Redundant state
Redundant functions
It can also be redundant relationships, design, construction, etc…
Anything that is redundant will cause maintenance problem
23. Avoid RedundancyAvoid Redundancy
The “once and only once” rule
If you are going to copy and paste, ask yourself
What is the code I want to reuse?
Can I make a new method that can be used by both my current
method and the place I need to use this similar functionality?
If 2 entities need to do this, how likely will there be a third, fourth,
etc…
Writing Quality code David Bernstein – 2008 p27 Copyright
24. Encapsulation – Information hidingEncapsulation – Information hiding
Two commonly used encapsulation methods
Data : The data needed for a class to fulfill it's responsibilities is hidden from
other entities
Implementation: How a class implements a particular function, or whether it
implements it itself or delegates to other objects, is hidden
Not so commonly used
Type: Abstract classes and interfaces can hide their implementing classes
Design: Assembling, collaborating classes with an object factory keeps clients
decoupled from the way they are designed (abstract factory)
Construction: Encapsulation of construction means wrapping "new" in, at
least, a separate method, giving you control over the return type (use of
getInstance)
25. TestabilityTestability
Class responsibility should be individually testable (unit
testing)
Considering how to test before developing or designing
leads to
Correctness
Good OO design
OO design patterns
And forces you to look at:
the public method definitions
what the responsibilities of the object are
Easy testability is achieved by strong cohesion, loose
coupling, good encapsulation and non redundancy
26. Role of TestabilityRole of Testability
You should always do unit testing. It helps
in code correctness
Whether you agree or not ask two things
You should always ask “ How will I test my
design / code?”
If you see that your code/ unit or design is not
testable, then there is something wrong in it.
Ask your self “How can I make this more
testable”
27. Assertive or InquisitiveAssertive or Inquisitive
In a relationship between two entities A and B
Should A ask the state of B and then use it
(inquisitive)
Should A tell B to do the task involving the
state (Assertive)
It does not increase the code or design, just who
takes the code and responsibility
Which is better?
28. Assertive vs. Inquisitive –Assertive vs. Inquisitive –
which is better?which is better?
The more Assertive you code / design is the more
decoupled you code or design is
Remember the “Gang of Four”: Design to interfaces. An
object's state is generally a part of its implementation.
We should not design to that, as it is highly likely to
change
"He who holds the state should hold the function"
Favor Assertiveness over Inquisitiveness (tell
but not Ask principle)
29. Organizing Principles
Cohesion is an organizing principle in that it helps us
decide where new entities belong
Coupling is an organizing principle in that it helps us
decide how different entities should talk to each other
(the interfaces)
Eliminating redundancy is an organizing principle
because it tells us to bring together redundant
methods/rules into a single place
30. Clarity Principles
How to document code
Implementation details (documentation) should be in the code, not as comments
If you have to write comments explaining “names”, your naming conventions
might be having issues
There is BIG difference between comments about “what” you are doing and
comments “why” (business rules)
Conceptual information can often be documented in abstract classes and
interfaces
Naming is not always easy. It is often a good idea to pair on naming issues
Always format code properly
(refer http://tutorials.rezg.net/Java/CodeConventions.pdf )
Try not have more the
100 characters per line
30 lines in a method
30 methods per class
31. SummarySummary
Remember the Code QualitiesRemember the Code Qualities
T – TestabilityT – Testability
R – Non RedundancyR – Non Redundancy
E – EncapsulationE – Encapsulation
C – CohesionC – Cohesion
C – Correct CouplingC – Correct Coupling
A – AssertiveA – Assertive
T.R.E.C.C.A.T.R.E.C.C.A.
Writing Quality code David Bernstein – 2008 p54 Copyright
32. Summary – In a NutshellSummary – In a Nutshell
In order of importance
Be testable
Contain no duplication (once and only once)
Loose coupling, strong cohesion and clarity
When writing, always program by intention
Methods and classes should be implemented so they can be
understood totally from their names and their public interfaces. This
flows naturally from up front testing, and decreases coupling‐
Classes should organize ideas in a readily understandable way
Use intention revealing names so you don't have to explain‐
method, member or class names with additional comments
Adhere to a coding standard