SlideShare a Scribd company logo
programming
    basics
    basics

Ladislav Martincik
Content
   - Simple question
   - Complexity OF MODELING
     reality (Not-reality)
   - OOP
   - Coupling (Connascence)
   - big applouse ;)

ALL the time discussion please!
Why oop?
class Component
  attr_accessor :name, :price

  def initialize name, price
    @name = name
    @price = price
  end

  def to_s
    "#{name}: $#{price}"
  end
end
What is better?
def pay(from, to, amount, rounding = 0.5)
  ....
end


def pay(transaction)
  ....
end
Holy OOP

   Keep “large”* software projects
   manageable by human
   programmers.




* what is LARGE?
Real Programming

   HUMAN to HUMAN **

   Complexity our brain can
   handle 4/+-2



** This is one of the reasons why we have high-level
programming languages and not assembler.
REal OOP
Modeling based on Real world experience and
Mathematics

- Modularization- Abstraction -- Understandability
- Encapsulation -- Information Hiding-
Composability -- Structured Design- Hierarchy-
Continuity
Modularization




 Decompose problem into smaller subproblems
 that can be solved separately.
Modularization
 class Component
   include PrintableComponent
   attr_reader :name, :price
   ...
 end

 module PrintableComponent
   def to_s
     "#{name}: $#{price}"
   end
 end
Abstraction --
Understandability



 Terminology of the problem domain is reflected
 in the software solution. Individual modules are
 understandable by human readers.
Abstraction --
Understandability
 set :environment, :development
 set :user, :deploy

 desc "Deploy to production"
 task :deploy do
   scp :local, "deploy@#{server}/#{root_dir}"
 end
Composability --
Structured Design



 Interfaces allow to freely combine modules to
 produce new systems.
Composability --
Structured Design
  gem "bundler"

  plugins

  module Namespace
    module Namespace2
      class X; end
      class Y < X; end
    end
  end
Hierarchy

 class Component
   attr_reader :sub_components
 end

 class Car < Component
   def initialize(color, type)
     @sub_components << Wheel.new('left top')
     @sub_components << Door.new('left driver')
   end
 end
Continuity




 Changes and maintenance in
 only a few modules does not affect
 the architecture.
Continuity
 DRY - Do not repeat yourself
 Coupling - ConNascence
ConNascence

Two software components are connascent if a
change in one would require the other to be
modified in order to maintain the overall
correctness of the system. Connascence is a
way to characterize and reason about certain
types of complexity in software systems.
ConNascence
Strength - The stronger the form of connascence, the more difficult,
and costly, it is to change the elements in the relationship.
Name < Type < Meaning < Position < ...
Degree - The acceptability of connascence is related to the degree
of its occurrence.def fun1(x1, x2) < def fun1(x1, x2, x3, x4, ...)
Locality - Stronger forms of connascence are acceptable if the
elements involved are closely related.
 - Stronger forms of connascence are acceptable if the elements
involved are closely related.
 - Stronger forms of connascence are acceptable if the elements
involved are closely related.
 - Stronger forms of connascence are acceptable if the elements
involved are closely related.
 - Stronger forms of connascence are acceptable if the elements
involved are closely related.
C of Name
 def pay(from, to, amount, correction)
   transaction do
     from.move(to, amount, correction)
   end
 end
C of TYPE
    def pay(transaction)
      if transaction.kind_of? Array

                                      DUCK TYPING
        transaction.each do |t|
          t.run
        end
      else
        transaction.run               def pay(transaction)
      end                               if transaction.respond_to :each
    end                                   transaction.each do |t|
                                             t.run
                                          end
                                        else
                                          transaction.run
                                        end
def pay(transaction)                  end
  Array(transaction).each do |x|
    x.run
  end
end
C of MEANING
class Role
  def can_access_admin?(role_id = 0)
    if role_id == 1     # Admin
      true
    elsif role_id == 2 # Ambassador
      true
    else
      false
    end                         class Role
  end                             ADMIN = 1; AMBASSADOR = 2
end                               def can_access_admin?(role_id = 0)
                                    if role_id == ADMIN
                                      true
                                    elsif role_id == AMBASSADOR
                                      true
                                    else
                                      false
                                    end
                                  end
                                end
C of Position
def pay(from, to, amount, correction)
  ....
end

def pay(options = {})
  ....
end



                        def pay(from, to, options = {})
                          ...
                        end
C of Algorithm
 class User
   def self.encrypt_password
     Digest::SHA1.hexdigest(password)
   end
 end

 class User
   attr_writer :encryption

   def initialize
     encryption = Digest::SHA1.hexdigest
   end

   def self.encrypt_password
     encryption.call password
   end
 end
Conclusion


  Name < Type < Meaning < Position < ALGORITHM
   Name < Type < Meaning < Position < ALGORITHM
Thank you


 Questions? Opinions?

 ladislav.martincik@gmail.com
 martincik.com
            martincik.com
OOP - NEXT time
- Single responsibility principle
- Open/closed principle
- Liskov substitution principle
- Interface segregation principle
- Dependency inversion principle

More Related Content

What's hot (19)

PPT
C C++ tutorial for beginners- tibacademy.in
TIB Academy
 
PPTX
Concept of scoping in programming languages
Md. Jafar Sadik
 
PPTX
Powerpoint presentation final requirement in fnd prg
alyssa-castro2326
 
PPT
Flow of Control
Praveen M Jigajinni
 
PDF
Swift Programming
Codemotion
 
PPTX
VB Script
Satish Sukumaran
 
PDF
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
Mark Simon
 
PPTX
Final requirement in programming niperos
markings17
 
PDF
Monad Fact #6
Philip Schwarz
 
PPTX
Final requirement in programming vinson
monstergeorge
 
PPT
Vb script
Aamir Sohail
 
PPTX
Final project powerpoint template (fndprg) (1)
heoff
 
PDF
C++ STATEMENTS
Prof Ansari
 
DOCX
Vb script tutorial
Abhishek Kesharwani
 
PPT
Kuliah komputer pemrograman
hardryu
 
PDF
C++ Chapter II
Sorn Chanratha
 
PPT
Intorudction into VBScript
Vitaliy Ganzha
 
PPTX
Flow of control by deepak lakhlan
Deepak Lakhlan
 
PPTX
Conditional statement c++
amber chaudary
 
C C++ tutorial for beginners- tibacademy.in
TIB Academy
 
Concept of scoping in programming languages
Md. Jafar Sadik
 
Powerpoint presentation final requirement in fnd prg
alyssa-castro2326
 
Flow of Control
Praveen M Jigajinni
 
Swift Programming
Codemotion
 
VB Script
Satish Sukumaran
 
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
Mark Simon
 
Final requirement in programming niperos
markings17
 
Monad Fact #6
Philip Schwarz
 
Final requirement in programming vinson
monstergeorge
 
Vb script
Aamir Sohail
 
Final project powerpoint template (fndprg) (1)
heoff
 
C++ STATEMENTS
Prof Ansari
 
Vb script tutorial
Abhishek Kesharwani
 
Kuliah komputer pemrograman
hardryu
 
C++ Chapter II
Sorn Chanratha
 
Intorudction into VBScript
Vitaliy Ganzha
 
Flow of control by deepak lakhlan
Deepak Lakhlan
 
Conditional statement c++
amber chaudary
 

Viewers also liked (11)

PPTX
Object Oriented Programming Basics
Malik Ghulam Murtza
 
PPTX
Programming Basics
Abhishek Pratap Singh
 
PDF
Super team
Ladislav Martincik
 
KEY
Programming SOLID
Ladislav Martincik
 
PDF
People Pattern Power
Ladislav Martincik
 
PDF
Efektivní učení
Ladislav Martincik
 
PPTX
Super kariera
Ladislav Martincik
 
PPTX
SOLID Principles of Refactoring Presentation - Inland Empire User Group
Adnan Masood
 
PPT
The Basics of programming
692sfrobotics
 
PPSX
C programming basics
argusacademy
 
PDF
Creating HTML Pages
Mike Crabb
 
Object Oriented Programming Basics
Malik Ghulam Murtza
 
Programming Basics
Abhishek Pratap Singh
 
Super team
Ladislav Martincik
 
Programming SOLID
Ladislav Martincik
 
People Pattern Power
Ladislav Martincik
 
Efektivní učení
Ladislav Martincik
 
Super kariera
Ladislav Martincik
 
SOLID Principles of Refactoring Presentation - Inland Empire User Group
Adnan Masood
 
The Basics of programming
692sfrobotics
 
C programming basics
argusacademy
 
Creating HTML Pages
Mike Crabb
 
Ad

Similar to Programming basics (20)

KEY
Refactor like a boss
gsterndale
 
PDF
Design Patterns the Ruby way - ConFoo 2015
Fred Heath
 
KEY
Intro to Ruby
Brian Hogan
 
KEY
Intro to Ruby - Twin Cities Code Camp 7
Brian Hogan
 
PDF
A Critical Look at Fixtures
ActsAsCon
 
PPT
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Anton Shemerey
 
PDF
Ruby on Rails 中級者を目指して - 大場寧子
Yasuko Ohba
 
KEY
Desarrollando aplicaciones web en minutos
Edgar Suarez
 
PDF
Rails workshop for Java people (September 2015)
Andre Foeken
 
PDF
Ruby and Rails by Example (GeekCamp edition)
bryanbibat
 
PDF
Ruby 程式語言入門導覽
Wen-Tien Chang
 
KEY
SOLID Ruby, SOLID Rails
Jens-Christian Fischer
 
KEY
Intro To Advanced Ruby
Brian Hogan
 
PDF
The Building Blocks Of Modularity
LittleBIGRuby
 
PDF
Ruby and Rails by example
bryanbibat
 
PDF
Story for a Ruby on Rails Single Engineer
TylerJohnson988371
 
PDF
SOLID Ruby SOLID Rails
Michael Mahlberg
 
PDF
Ruby on Rails ステップアップ講座 - 大場寧子
Yasuko Ohba
 
PDF
Slides chapter3part1 ruby-forjavaprogrammers
Giovanni924
 
PDF
Ruby on Rails
bryanbibat
 
Refactor like a boss
gsterndale
 
Design Patterns the Ruby way - ConFoo 2015
Fred Heath
 
Intro to Ruby
Brian Hogan
 
Intro to Ruby - Twin Cities Code Camp 7
Brian Hogan
 
A Critical Look at Fixtures
ActsAsCon
 
Ruby: OOP, metaprogramming, blocks, iterators, mix-ins, duck typing. Code style
Anton Shemerey
 
Ruby on Rails 中級者を目指して - 大場寧子
Yasuko Ohba
 
Desarrollando aplicaciones web en minutos
Edgar Suarez
 
Rails workshop for Java people (September 2015)
Andre Foeken
 
Ruby and Rails by Example (GeekCamp edition)
bryanbibat
 
Ruby 程式語言入門導覽
Wen-Tien Chang
 
SOLID Ruby, SOLID Rails
Jens-Christian Fischer
 
Intro To Advanced Ruby
Brian Hogan
 
The Building Blocks Of Modularity
LittleBIGRuby
 
Ruby and Rails by example
bryanbibat
 
Story for a Ruby on Rails Single Engineer
TylerJohnson988371
 
SOLID Ruby SOLID Rails
Michael Mahlberg
 
Ruby on Rails ステップアップ講座 - 大場寧子
Yasuko Ohba
 
Slides chapter3part1 ruby-forjavaprogrammers
Giovanni924
 
Ruby on Rails
bryanbibat
 
Ad

Recently uploaded (20)

PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 

Programming basics

  • 1. programming basics basics Ladislav Martincik
  • 2. Content - Simple question - Complexity OF MODELING reality (Not-reality) - OOP - Coupling (Connascence) - big applouse ;) ALL the time discussion please!
  • 3. Why oop? class Component attr_accessor :name, :price def initialize name, price @name = name @price = price end def to_s "#{name}: $#{price}" end end
  • 4. What is better? def pay(from, to, amount, rounding = 0.5) .... end def pay(transaction) .... end
  • 5. Holy OOP Keep “large”* software projects manageable by human programmers. * what is LARGE?
  • 6. Real Programming HUMAN to HUMAN ** Complexity our brain can handle 4/+-2 ** This is one of the reasons why we have high-level programming languages and not assembler.
  • 7. REal OOP Modeling based on Real world experience and Mathematics - Modularization- Abstraction -- Understandability - Encapsulation -- Information Hiding- Composability -- Structured Design- Hierarchy- Continuity
  • 8. Modularization Decompose problem into smaller subproblems that can be solved separately.
  • 9. Modularization class Component include PrintableComponent attr_reader :name, :price ... end module PrintableComponent def to_s "#{name}: $#{price}" end end
  • 10. Abstraction -- Understandability Terminology of the problem domain is reflected in the software solution. Individual modules are understandable by human readers.
  • 11. Abstraction -- Understandability set :environment, :development set :user, :deploy desc "Deploy to production" task :deploy do scp :local, "deploy@#{server}/#{root_dir}" end
  • 12. Composability -- Structured Design Interfaces allow to freely combine modules to produce new systems.
  • 13. Composability -- Structured Design gem "bundler" plugins module Namespace module Namespace2 class X; end class Y < X; end end end
  • 14. Hierarchy class Component attr_reader :sub_components end class Car < Component def initialize(color, type) @sub_components << Wheel.new('left top') @sub_components << Door.new('left driver') end end
  • 15. Continuity Changes and maintenance in only a few modules does not affect the architecture.
  • 16. Continuity DRY - Do not repeat yourself Coupling - ConNascence
  • 17. ConNascence Two software components are connascent if a change in one would require the other to be modified in order to maintain the overall correctness of the system. Connascence is a way to characterize and reason about certain types of complexity in software systems.
  • 18. ConNascence Strength - The stronger the form of connascence, the more difficult, and costly, it is to change the elements in the relationship. Name < Type < Meaning < Position < ... Degree - The acceptability of connascence is related to the degree of its occurrence.def fun1(x1, x2) < def fun1(x1, x2, x3, x4, ...) Locality - Stronger forms of connascence are acceptable if the elements involved are closely related. - Stronger forms of connascence are acceptable if the elements involved are closely related. - Stronger forms of connascence are acceptable if the elements involved are closely related. - Stronger forms of connascence are acceptable if the elements involved are closely related. - Stronger forms of connascence are acceptable if the elements involved are closely related.
  • 19. C of Name def pay(from, to, amount, correction) transaction do from.move(to, amount, correction) end end
  • 20. C of TYPE def pay(transaction) if transaction.kind_of? Array DUCK TYPING transaction.each do |t| t.run end else transaction.run def pay(transaction) end if transaction.respond_to :each end transaction.each do |t| t.run end else transaction.run end def pay(transaction) end Array(transaction).each do |x| x.run end end
  • 21. C of MEANING class Role def can_access_admin?(role_id = 0) if role_id == 1 # Admin true elsif role_id == 2 # Ambassador true else false end class Role end ADMIN = 1; AMBASSADOR = 2 end def can_access_admin?(role_id = 0) if role_id == ADMIN true elsif role_id == AMBASSADOR true else false end end end
  • 22. C of Position def pay(from, to, amount, correction) .... end def pay(options = {}) .... end def pay(from, to, options = {}) ... end
  • 23. C of Algorithm class User def self.encrypt_password Digest::SHA1.hexdigest(password) end end class User attr_writer :encryption def initialize encryption = Digest::SHA1.hexdigest end def self.encrypt_password encryption.call password end end
  • 24. Conclusion Name < Type < Meaning < Position < ALGORITHM Name < Type < Meaning < Position < ALGORITHM
  • 25. Thank you Questions? Opinions? [email protected] martincik.com martincik.com
  • 26. OOP - NEXT time - Single responsibility principle - Open/closed principle - Liskov substitution principle - Interface segregation principle - Dependency inversion principle