SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Programing
Techniques
By Prabhjit Singh
Why we need Programing
Techniques ?
Programing technique is about generalizing software
components so that they can be easily reused in a wide
variety of situations. Programming techniques include :
1) Complexity factor
2) Using bitwise operators
3) Iteration vs Recursions
4) Implementing design patterns
Lets starts with Arrays
• An array is a collection of variables where each variable
has the same data type.
• Each variable in an array is called an element and has an
index, also called the subscript, which denotes that
element’s location within the array.
• One advantage of using arrays is that all the elements
within an array can be declared, created, and passed to a
function as a whole.
• Arrays are of two types fixed memory allocation (fixed
length) or array list (unlimted size).
Complexity Factor : Lets
starts with Arrays
• How to reverse an Array.
• First Method used an Inbuilt method. (EASY)
• Iterate from last index of array to index 0 and put all
elements in new array. here it loops for n times, where n is
number of items in an array.
• One way to reverse the elements in an array is to use two
index variables: one index starts at the beginning of the
array, and the other starts at the end of the array. Then
write a loop that repeats n / 2 times where n is the number
of elements in the array.
Complexity Factor : Lets
starts with Arrays
public static void reverse( float[] list) {
int left = 0;
int right = list.length - 1;
while (left < right) {
// Exchange two elements.
float swap = list[ left];
list[ left] = list[ right];
list[ right] = swap;
// Move the indices toward the center.
left + +;
right--;
}
}
Bit Operators
• A boolean variable, named after the British mathematician George Boole, is a variable that holds either false or true and
nothing else.
• An efficient way to store many boolean variables is in a group called a bitset where each boolean variable is stored in a single
bit with 0 meaning false and 1 meaning true.
• One important operation that must be performed on a bitset is to count how many bits are set, which is sometimes called the
population count.
• A bitwise operation is a manipulation of one or two binary numbers to produce another binary number.
• There are seven standard bitwise operations that a computer can perform: left shift unsigned right shift signed right shift not
and or exclusive or
• left shift (<<)
• unsigned left shift (>>>)
• signed right shift (>>)
• not (! or ~)
• and (&)
• or (||)
• exclusive or
Bit Operators
• The left shift operator is two less than symbols (< <) and shifts all the bits in an integer to the left by a specified
number of locations, filling the right-most bits with 0 and losing the values in the left-most bits.
• e.g : x = 58 ; x << 2 = 232 // 58 * 4 = 232 , x*2^n
58 0000 0000 0000 0000 0000 0000 0011 1010
232 0000 0000 0000 0000 0000 0000 1110 1000
• The unsigned right shift operator (also called the logical right shift operator ) is three greater than symbols (> > >)
and shifts all the bits in an integer to the right by a specified number of locations, filling the left-most bits with 0 and
losing the values in the right-most bits.
• e.g : x = 58 ; x >>> 2 = 14 // 58 / 4 = 14 , x/2^n
58 0000 0000 0000 0000 0000 0000 0011 1010
14 0000 0000 0000 0000 0000 0000 0000 1110
• In a two’s complement integer, the left-most bit is the sign bit and contains a 0 if the integer is non-negative and
contains a 1 if the integer is negative. The signed right shift operator (also called the arithmetic right shift
operator). Example same as above.
• The bitwise not operator is the tilde (~) and takes an integer as input and clears every set bit and sets every clear
bit, or in other words, switches every 1 bit to 0 and every 0 bit to 1.
Bit Operators
• The bitwise and operator is the ampersand (&) and takes two integers as input and produces an
integer with bits set where the bits are set in both inputs and clear everywhere else. This is the same
operation as logical and but performed on each bit. Within a program, bitwise and is often used to test if
a bit is set and to clear bits in a variable.
• The bitwise or operator is the vertical bar (|) and takes two integers as input and produces an integer
with bits set where the bits are set in either or both inputs and clear everywhere else. This is the same
operation as logical or but performed on each bit. Within a program, bitwise or is often used to set bits in
a variable.
• The bitwise exclusive or operator is the caret ( ^) and takes two integers as input and produces an
integer with bits set where the bits in the two inputs are different and clear everywhere else. This is the
same operation as logical exclusive or but performed on each bit . Within a program, bitwise exclusive
or is often used in data encryption and can even be used to swap the values of two variables.
• All the bitwise operators , except not (~), can be combined with the assignment operator (=) to make
shortcut operators. e.g. x <<=2, x &=0x0f
Bit Operators
write code to count the number of bits set to 1 in a 64-bit number. This is sometimes called the population count.
/** Returns the number of bits set in a 64-bit word. */ e.g 0x00 00 00 04 a0 3f 6e 8c.
public static int nbits( long word) {
int n = 0;
for (int i = 0; i != 64; + + i) {
if (( word & 1) != 0) {
+ + n;
}
word > > > = 1;}
return n;}
// More Faster way
public static int nbits( long word) {
int n = 0;
while (word != 0) {
if (( word & 1) != 0) {
+ + n; }
word > > > = 1; }
return n; }
Bit Operators
Addition Instead of If
Computers often execute if statements slowly because modern CPUs have a pipeline of instructions that are
in the process of being decoded and executed. When the CPU begins executing an if-else statement, before
it knows the value of the condition (true or false), it will predict that value (usually as true) and begin
speculatively executing the statements in the corresponding part of the if-else statement. However, when
the CPU finishes calculating the value of the condition, if it has predicted incorrectly, it must unload the
instruction pipeline and begin executing the statements in the other part of the if-else statement which takes
time. When an if statement does not have a matching else, the CPU must still predict whether the condition
is true or false and speculatively execute statements according to its prediction.
/** Returns the number of bits set in a 64-bit word. */
public static int nbits( long word) {
int n = 0;
while (word != 0) {
n + = (int) word & 1;
word > > > = 1;
}
return n;
}
Iteration and Recursion
• Iteration is the process of repeating a block of statements in a computer program by using a repetition control structure, also
known as a loop. Here is a simple example of iteration written in Java that computes n factorial (n!).
• Recursion is the process of repeating a block of statements in a computer program by using a recursive function. A recursive
function is a function that calls itself either directly or indirectly. A function F calls itself indirectly by calling function G which
calls function F. A recursive algorithm solves a problem by repeatedly dividing it into smaller sub-problems until reaching the
simpliest sub -problem and then solves that simpliest problem. All recursive algorithms must have three parts:
• A base case which is the simpliest sub-problem and when the recursion will stop
• Code to work toward the base case by dividing the problem into sub-problems
• One or more recursive function calls
/** Recursively computes n factorial (n!) * which is n * (n-1) * (n-2) * ... 1 */
public static long factorial( int n) {
if (n > 1) {
return n * factorial( n - 1);
}
return 1;
}
Iteration and Recursion
• Recursion began to make sense to me when I learned that
• Recursion comes to computer science from mathematics, and mathematicians
define some mathematical functions, such as the Fibonacci series, in a recursive
form.
• Some programming languages such as Erlang, ProLog, and Haskell, don’t include
iteration, because the inventors of those languages believed that iteration was error
prone and that recursive solutions revealed the intrinsic structure of a problem.
• There are many programming problems more complex than the simple recursive
examples shown in text books (such as n factorial) that are elegantly solved using
recursion.
Iteration and Recursion
• Advantages of Recursion
• If a computing problem can be broken into smaller self-similar problems, a recursive solution is almost always
shorter and more elegant than an iterative solution.
• A recursive function uses existing, well-understood, and tested functionality, namely the system stack, as part
of its solution instead of requiring that another stack module be written.
• It is sometimes necessary to prove that a computing solution is correct. Proving correctness is easier for a
recursive solution than an iterative solution because recursion and proof by induction are closely related.
• Disadvantages
• Using recursion means many function calls. In many programming languages, a function call is relatively slow
compared to other operations. In languages that don’t include iteration, the language compiler or interpreter will
transform some recursive functions into iterative ones to lower the number of function calls. If a programmer
writes a recursive function in a language that doesn’t include this optimization, that function will likely be much
slower than an iterative function that solves the same problem.
• Recursion can be hard to learn and understand especially for someone that has already learned iteration.
• A recursive function may use all the memory in the system stack which will cause the program to crash.
Design Pattern
In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within
a given context in software design. A design pattern is not a finished design that can be transformed directly into
source or machine code. It is a description or template for how to solve a problem that can be used in many
different situations. Patterns are formalized best practices that the programmer can use to solve common
problems when designing an application or system.
• Design patterns can speed up the development process by providing tested, proven development paradigms.
Effective software design requires considering issues that may not become visible until later in the
implementation. Reusing design patterns helps to prevent subtle issues that can cause major
problems[citation needed], and it also improves code readability for coders and architects who are familiar with
the patterns.
• By definition, a pattern must be programmed anew into each application that uses it. Since some authors see
this as a step backward from software reuse as provided by components, researchers have worked to turn
patterns into components.
• Design patterns were originally grouped into the categories: creational patterns, structural patterns, and
behavioral patterns, and described using the concepts of delegation, aggregation, and consultation. For further
background on object-oriented design, see coupling and cohesion, inheritance, interface, and polymorphism.
Another classification has also introduced the notion of architectural design pattern that may be applied at the
architecture level of the software such as the Model–View–Controller pattern.
Design Pattern
Creational Pattern
• Abstract Factory :
Provide an interface for creating families of related or dependent objects without
specifying their concrete classes.
• Builder
Separate the construction of a complex object from its representation, allowing the
same construction process to create various representations.
• Factory method
Define an interface for creating a single object, but let subclasses decide which
class to instantiate. Factory Method lets a class defer instantiation to subclasses
(dependency injection).
• Prototype
Specify the kinds of objects to create using a prototypical instance, and create new
objects by copying this prototype.
• Singleton
Ensure a class has only one instance, and provide a global point of access to it.
Design Pattern
Structural patterns
• Adapter or Wrapper or Translator.
Convert the interface of a class into another interface clients expect. An adapter lets classes work
together that could not otherwise because of incompatible interfaces. The enterprise integration pattern
equivalent is the translator.
• Composite
Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients
treat individual objects and compositions of objects uniformly.
• Decorator
Attach additional responsibilities to an object dynamically keeping the same interface. Decorators
provide a flexible alternative to subclassing for extending functionality.
• Facade
Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level
interface that makes the subsystem easier to use.
• Module
Group several related elements, such as classes, singletons, methods, globally used, into a single
conceptual entity.
• Front Controller
The pattern relates to the design of Web applications. It provides a centralized entry point for
handling requests.
Design Pattern
Behavioral patterns
• Blackboard
Generalized observer, which allows multiple readers and writers. Communicates information
system-wide.
• Interpreter
Given a language, define a representation for its grammar along with an interpreter that uses
the representation to interpret sentences in the language.
• Iterator
Provide a way to access the elements of an aggregate object sequentially without exposing its
underlying representation.
• Null object
Avoid null references by providing a default object.
• Strategy
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy
lets the algorithm vary independently from clients that use it.
• Template method
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses.
Template method lets subclasses redefine certain steps of an algorithm without changing the
algorithm's structure.
• State
Allow an object to alter its behavior when its internal state changes. The object will appear to
change its class.
Design Pattern
Concurrency patterns
• Active Object
Decouples method execution from method invocation that reside in their own thread of control.
The goal is to introduce concurrency, by using asynchronous method invocation and a scheduler for
handling requests.
• Balking
Only execute an action on an object when the object is in a particular state.
• Messaging design pattern (MDP)
Allows the interchange of information (i.e. messages) between components and applications.
• Monitor object
An object whose methods are subject to mutual exclusion, thus preventing multiple objects from
erroneously trying to use it at the same time.
• Event-based asynchronous
Addresses problems with the asynchronous pattern that occur in multithreaded programs.
• Join
Join-patterns provides a way to write concurrent, parallel and distributed programs by message
passing. Compared to the use of threads and locks, this is a high level programming model.
• Lock
One thread puts a "lock" on a resource, preventing other threads from accessing or modifying it.
Last But Not Least
Characteristics of a bad Programmer
• The StackOverflow bot
• The I-am-not-a-tester
• The I-hate-documentation
• The ugly: My code works, but:
• Have variables named x, flag, str, arr, etc.
• -Most of what I write is in one giant method.
• -There is no indentation.
• -No consistent coding convention or style.
• -Global variables spewed all over the place, etc.
• The short-term investor
• He codes. He deploys. He moves on. No attempt to learn the problem. No interest in the domain. Just give
this guy a piece of code, he will slog on it overnight and hand it over.
• The protester
• “I didn’t do this”.
• “This looks bad”.
• “Not my problem”.
• “This isn’t related really to my fix, but someone way over there made a mistake”.
• “I hate this (loop this sentence 10 times a day)”.
• “I can’t fix this, get the person who made this code to fix it”.
• The dictator : My way or the highway
• The overcautious
• The careless
• Forgets to take a backup, snapshots, has multiple working directories of code.
• The lazy pseudo-hacker
• Just Use tricks to make it work for now.
Thanks Guys
For wasting your precious time with me.

Weitere ähnliche Inhalte

Was ist angesagt?

Presentation on Programming Languages.
Presentation on Programming Languages.Presentation on Programming Languages.
Presentation on Programming Languages.Mohammad Shakirul islam
 
Theory of programming
Theory of programmingTheory of programming
Theory of programmingtcc_joemarie
 
Computer languages 11
Computer languages 11Computer languages 11
Computer languages 11Muhammad Ramzan
 
Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming languageJAIDEVPAUL
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentationfazli khaliq
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating SystemsMukesh Chinta
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler DesignMuhammed Afsal Villan
 
Computer graphics chapter 4
Computer graphics chapter 4Computer graphics chapter 4
Computer graphics chapter 4PrathimaBaliga
 
Web Application Design
Web Application DesignWeb Application Design
Web Application DesignHemin Patel
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programmingManoj Tyagi
 
Number System
Number SystemNumber System
Number SystemZahid Rajeel
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreterParas Patel
 
Programming Fundamentals lecture 2
Programming Fundamentals lecture 2Programming Fundamentals lecture 2
Programming Fundamentals lecture 2REHAN IJAZ
 
Software development slides
Software development slidesSoftware development slides
Software development slidesiarthur
 
Python Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaPython Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaEdureka!
 

Was ist angesagt? (20)

Presentation on Programming Languages.
Presentation on Programming Languages.Presentation on Programming Languages.
Presentation on Programming Languages.
 
Programming
ProgrammingProgramming
Programming
 
Theory of programming
Theory of programmingTheory of programming
Theory of programming
 
Compilers
CompilersCompilers
Compilers
 
Computer languages 11
Computer languages 11Computer languages 11
Computer languages 11
 
Generations of programming language
Generations of programming languageGenerations of programming language
Generations of programming language
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating Systems
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Computer graphics chapter 4
Computer graphics chapter 4Computer graphics chapter 4
Computer graphics chapter 4
 
Web Application Design
Web Application DesignWeb Application Design
Web Application Design
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
Character set of c
Character set of cCharacter set of c
Character set of c
 
Number System
Number SystemNumber System
Number System
 
Introduction python
Introduction pythonIntroduction python
Introduction python
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
Programming Fundamentals lecture 2
Programming Fundamentals lecture 2Programming Fundamentals lecture 2
Programming Fundamentals lecture 2
 
Software development slides
Software development slidesSoftware development slides
Software development slides
 
Python Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaPython Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | Edureka
 

Andere mochten auch

Programming II LAB 2 - OOP
Programming II LAB 2 - OOP Programming II LAB 2 - OOP
Programming II LAB 2 - OOP Fares Younis
 
Recursion and looping
Recursion and loopingRecursion and looping
Recursion and loopingxcoolanurag
 
Programming II LAB 3 - OOP
Programming II LAB 3 - OOPProgramming II LAB 3 - OOP
Programming II LAB 3 - OOPFares Younis
 
Programming II LAB 4 (OOP) inheritance
Programming II LAB 4 (OOP)  inheritanceProgramming II LAB 4 (OOP)  inheritance
Programming II LAB 4 (OOP) inheritanceFares Younis
 
Basic programming
Basic programmingBasic programming
Basic programmingJugul Crasta
 
Computer programing
Computer programingComputer programing
Computer programingJT Taylor
 
Object-Oriented Programming 2
Object-Oriented Programming 2Object-Oriented Programming 2
Object-Oriented Programming 2Warawut
 
System software lecture infs429
System software lecture infs429System software lecture infs429
System software lecture infs429Edmund Sowah
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programmingJordan Delacruz
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming692sfrobotics
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04hassaanciit
 
Programing Fundamental
Programing FundamentalPrograming Fundamental
Programing FundamentalQazi Shahzad Ali
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programmingRoger Argarin
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointJavaTpoint.Com
 
Computer Languages.
Computer Languages.Computer Languages.
Computer Languages.Aditya Sheoran
 
Programming language
Programming languageProgramming language
Programming languageMakku-Sama
 
Beginning programming for dummies 3rd edition
Beginning programming for dummies 3rd editionBeginning programming for dummies 3rd edition
Beginning programming for dummies 3rd editionAndrea Filippo
 

Andere mochten auch (20)

Programming II LAB 2 - OOP
Programming II LAB 2 - OOP Programming II LAB 2 - OOP
Programming II LAB 2 - OOP
 
Recursion and looping
Recursion and loopingRecursion and looping
Recursion and looping
 
Programming II LAB 3 - OOP
Programming II LAB 3 - OOPProgramming II LAB 3 - OOP
Programming II LAB 3 - OOP
 
Programming II LAB 4 (OOP) inheritance
Programming II LAB 4 (OOP)  inheritanceProgramming II LAB 4 (OOP)  inheritance
Programming II LAB 4 (OOP) inheritance
 
Basic programming
Basic programmingBasic programming
Basic programming
 
Computer programing
Computer programingComputer programing
Computer programing
 
Computer Programing
Computer ProgramingComputer Programing
Computer Programing
 
Object-Oriented Programming 2
Object-Oriented Programming 2Object-Oriented Programming 2
Object-Oriented Programming 2
 
System software lecture infs429
System software lecture infs429System software lecture infs429
System software lecture infs429
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programming
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04
 
Programing Fundamental
Programing FundamentalPrograming Fundamental
Programing Fundamental
 
Basic programming
Basic programmingBasic programming
Basic programming
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programming
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
Computer Languages.
Computer Languages.Computer Languages.
Computer Languages.
 
Programming language
Programming languageProgramming language
Programming language
 
Beginning programming for dummies 3rd edition
Beginning programming for dummies 3rd editionBeginning programming for dummies 3rd edition
Beginning programming for dummies 3rd edition
 

Ähnlich wie Programing techniques

Function in C++, Methods in C++ coding programming
Function in C++, Methods in C++ coding programmingFunction in C++, Methods in C++ coding programming
Function in C++, Methods in C++ coding programmingestorebackupr
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptxVAIBHAVKADAGANCHI
 
Report on c
Report on cReport on c
Report on cjasmeen kr
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++Online
 
Python Programming unit5 (1).pdf
Python Programming unit5 (1).pdfPython Programming unit5 (1).pdf
Python Programming unit5 (1).pdfjamvantsolanki
 
Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...
Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...
Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...IJERD Editor
 
Q-Step_WS_02102019_Practical_introduction_to_Python.pdf
Q-Step_WS_02102019_Practical_introduction_to_Python.pdfQ-Step_WS_02102019_Practical_introduction_to_Python.pdf
Q-Step_WS_02102019_Practical_introduction_to_Python.pdfMichpice
 
Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5FabMinds
 
classVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxclassVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxssusere336f4
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golangwww.ixxo.io
 
02 functions, variables, basic input and output of c++
02   functions, variables, basic input and output of c++02   functions, variables, basic input and output of c++
02 functions, variables, basic input and output of c++Manzoor ALam
 
C programming language
C programming languageC programming language
C programming languageAbin Rimal
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - ModifiersMichael Heron
 
C language
C languageC language
C languageRobo India
 
Low Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).pptLow Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).pptLearnWithJCM
 

Ähnlich wie Programing techniques (20)

Function in C++, Methods in C++ coding programming
Function in C++, Methods in C++ coding programmingFunction in C++, Methods in C++ coding programming
Function in C++, Methods in C++ coding programming
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
Basics of cpp
Basics of cppBasics of cpp
Basics of cpp
 
Report on c
Report on cReport on c
Report on c
 
Operation and expression in c++
Operation and expression in c++Operation and expression in c++
Operation and expression in c++
 
Python Programming unit5 (1).pdf
Python Programming unit5 (1).pdfPython Programming unit5 (1).pdf
Python Programming unit5 (1).pdf
 
Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...
Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...
Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...
 
Q-Step_WS_02102019_Practical_introduction_to_Python.pdf
Q-Step_WS_02102019_Practical_introduction_to_Python.pdfQ-Step_WS_02102019_Practical_introduction_to_Python.pdf
Q-Step_WS_02102019_Practical_introduction_to_Python.pdf
 
CPP07 - Scope
CPP07 - ScopeCPP07 - Scope
CPP07 - Scope
 
Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5Python Programming | JNTUK | UNIT 1 | Lecture 5
Python Programming | JNTUK | UNIT 1 | Lecture 5
 
classVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptxclassVII_Coding_Teacher_Presentation.pptx
classVII_Coding_Teacher_Presentation.pptx
 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golang
 
02 functions, variables, basic input and output of c++
02   functions, variables, basic input and output of c++02   functions, variables, basic input and output of c++
02 functions, variables, basic input and output of c++
 
C programming language
C programming languageC programming language
C programming language
 
Programming in C.pptx
Programming in C.pptxProgramming in C.pptx
Programming in C.pptx
 
embedded C.pptx
embedded C.pptxembedded C.pptx
embedded C.pptx
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - Modifiers
 
C language
C languageC language
C language
 
Low Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).pptLow Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).ppt
 

KĂźrzlich hochgeladen

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

KĂźrzlich hochgeladen (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Programing techniques

  • 2. Why we need Programing Techniques ? Programing technique is about generalizing software components so that they can be easily reused in a wide variety of situations. Programming techniques include : 1) Complexity factor 2) Using bitwise operators 3) Iteration vs Recursions 4) Implementing design patterns
  • 3. Lets starts with Arrays • An array is a collection of variables where each variable has the same data type. • Each variable in an array is called an element and has an index, also called the subscript, which denotes that element’s location within the array. • One advantage of using arrays is that all the elements within an array can be declared, created, and passed to a function as a whole. • Arrays are of two types fixed memory allocation (fixed length) or array list (unlimted size).
  • 4. Complexity Factor : Lets starts with Arrays • How to reverse an Array. • First Method used an Inbuilt method. (EASY) • Iterate from last index of array to index 0 and put all elements in new array. here it loops for n times, where n is number of items in an array. • One way to reverse the elements in an array is to use two index variables: one index starts at the beginning of the array, and the other starts at the end of the array. Then write a loop that repeats n / 2 times where n is the number of elements in the array.
  • 5. Complexity Factor : Lets starts with Arrays public static void reverse( float[] list) { int left = 0; int right = list.length - 1; while (left < right) { // Exchange two elements. float swap = list[ left]; list[ left] = list[ right]; list[ right] = swap; // Move the indices toward the center. left + +; right--; } }
  • 6. Bit Operators • A boolean variable, named after the British mathematician George Boole, is a variable that holds either false or true and nothing else. • An efficient way to store many boolean variables is in a group called a bitset where each boolean variable is stored in a single bit with 0 meaning false and 1 meaning true. • One important operation that must be performed on a bitset is to count how many bits are set, which is sometimes called the population count. • A bitwise operation is a manipulation of one or two binary numbers to produce another binary number. • There are seven standard bitwise operations that a computer can perform: left shift unsigned right shift signed right shift not and or exclusive or • left shift (<<) • unsigned left shift (>>>) • signed right shift (>>) • not (! or ~) • and (&) • or (||) • exclusive or
  • 7. Bit Operators • The left shift operator is two less than symbols (< <) and shifts all the bits in an integer to the left by a specified number of locations, filling the right-most bits with 0 and losing the values in the left-most bits. • e.g : x = 58 ; x << 2 = 232 // 58 * 4 = 232 , x*2^n 58 0000 0000 0000 0000 0000 0000 0011 1010 232 0000 0000 0000 0000 0000 0000 1110 1000 • The unsigned right shift operator (also called the logical right shift operator ) is three greater than symbols (> > >) and shifts all the bits in an integer to the right by a specified number of locations, filling the left-most bits with 0 and losing the values in the right-most bits. • e.g : x = 58 ; x >>> 2 = 14 // 58 / 4 = 14 , x/2^n 58 0000 0000 0000 0000 0000 0000 0011 1010 14 0000 0000 0000 0000 0000 0000 0000 1110 • In a two’s complement integer, the left-most bit is the sign bit and contains a 0 if the integer is non-negative and contains a 1 if the integer is negative. The signed right shift operator (also called the arithmetic right shift operator). Example same as above. • The bitwise not operator is the tilde (~) and takes an integer as input and clears every set bit and sets every clear bit, or in other words, switches every 1 bit to 0 and every 0 bit to 1.
  • 8. Bit Operators • The bitwise and operator is the ampersand (&) and takes two integers as input and produces an integer with bits set where the bits are set in both inputs and clear everywhere else. This is the same operation as logical and but performed on each bit. Within a program, bitwise and is often used to test if a bit is set and to clear bits in a variable. • The bitwise or operator is the vertical bar (|) and takes two integers as input and produces an integer with bits set where the bits are set in either or both inputs and clear everywhere else. This is the same operation as logical or but performed on each bit. Within a program, bitwise or is often used to set bits in a variable. • The bitwise exclusive or operator is the caret ( ^) and takes two integers as input and produces an integer with bits set where the bits in the two inputs are different and clear everywhere else. This is the same operation as logical exclusive or but performed on each bit . Within a program, bitwise exclusive or is often used in data encryption and can even be used to swap the values of two variables. • All the bitwise operators , except not (~), can be combined with the assignment operator (=) to make shortcut operators. e.g. x <<=2, x &=0x0f
  • 9. Bit Operators write code to count the number of bits set to 1 in a 64-bit number. This is sometimes called the population count. /** Returns the number of bits set in a 64-bit word. */ e.g 0x00 00 00 04 a0 3f 6e 8c. public static int nbits( long word) { int n = 0; for (int i = 0; i != 64; + + i) { if (( word & 1) != 0) { + + n; } word > > > = 1;} return n;} // More Faster way public static int nbits( long word) { int n = 0; while (word != 0) { if (( word & 1) != 0) { + + n; } word > > > = 1; } return n; }
  • 10. Bit Operators Addition Instead of If Computers often execute if statements slowly because modern CPUs have a pipeline of instructions that are in the process of being decoded and executed. When the CPU begins executing an if-else statement, before it knows the value of the condition (true or false), it will predict that value (usually as true) and begin speculatively executing the statements in the corresponding part of the if-else statement. However, when the CPU finishes calculating the value of the condition, if it has predicted incorrectly, it must unload the instruction pipeline and begin executing the statements in the other part of the if-else statement which takes time. When an if statement does not have a matching else, the CPU must still predict whether the condition is true or false and speculatively execute statements according to its prediction. /** Returns the number of bits set in a 64-bit word. */ public static int nbits( long word) { int n = 0; while (word != 0) { n + = (int) word & 1; word > > > = 1; } return n; }
  • 11. Iteration and Recursion • Iteration is the process of repeating a block of statements in a computer program by using a repetition control structure, also known as a loop. Here is a simple example of iteration written in Java that computes n factorial (n!). • Recursion is the process of repeating a block of statements in a computer program by using a recursive function. A recursive function is a function that calls itself either directly or indirectly. A function F calls itself indirectly by calling function G which calls function F. A recursive algorithm solves a problem by repeatedly dividing it into smaller sub-problems until reaching the simpliest sub -problem and then solves that simpliest problem. All recursive algorithms must have three parts: • A base case which is the simpliest sub-problem and when the recursion will stop • Code to work toward the base case by dividing the problem into sub-problems • One or more recursive function calls /** Recursively computes n factorial (n!) * which is n * (n-1) * (n-2) * ... 1 */ public static long factorial( int n) { if (n > 1) { return n * factorial( n - 1); } return 1; }
  • 12. Iteration and Recursion • Recursion began to make sense to me when I learned that • Recursion comes to computer science from mathematics, and mathematicians define some mathematical functions, such as the Fibonacci series, in a recursive form. • Some programming languages such as Erlang, ProLog, and Haskell, don’t include iteration, because the inventors of those languages believed that iteration was error prone and that recursive solutions revealed the intrinsic structure of a problem. • There are many programming problems more complex than the simple recursive examples shown in text books (such as n factorial) that are elegantly solved using recursion.
  • 13. Iteration and Recursion • Advantages of Recursion • If a computing problem can be broken into smaller self-similar problems, a recursive solution is almost always shorter and more elegant than an iterative solution. • A recursive function uses existing, well-understood, and tested functionality, namely the system stack, as part of its solution instead of requiring that another stack module be written. • It is sometimes necessary to prove that a computing solution is correct. Proving correctness is easier for a recursive solution than an iterative solution because recursion and proof by induction are closely related. • Disadvantages • Using recursion means many function calls. In many programming languages, a function call is relatively slow compared to other operations. In languages that don’t include iteration, the language compiler or interpreter will transform some recursive functions into iterative ones to lower the number of function calls. If a programmer writes a recursive function in a language that doesn’t include this optimization, that function will likely be much slower than an iterative function that solves the same problem. • Recursion can be hard to learn and understand especially for someone that has already learned iteration. • A recursive function may use all the memory in the system stack which will cause the program to crash.
  • 14. Design Pattern In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system. • Design patterns can speed up the development process by providing tested, proven development paradigms. Effective software design requires considering issues that may not become visible until later in the implementation. Reusing design patterns helps to prevent subtle issues that can cause major problems[citation needed], and it also improves code readability for coders and architects who are familiar with the patterns. • By definition, a pattern must be programmed anew into each application that uses it. Since some authors see this as a step backward from software reuse as provided by components, researchers have worked to turn patterns into components. • Design patterns were originally grouped into the categories: creational patterns, structural patterns, and behavioral patterns, and described using the concepts of delegation, aggregation, and consultation. For further background on object-oriented design, see coupling and cohesion, inheritance, interface, and polymorphism. Another classification has also introduced the notion of architectural design pattern that may be applied at the architecture level of the software such as the Model–View–Controller pattern.
  • 15. Design Pattern Creational Pattern • Abstract Factory : Provide an interface for creating families of related or dependent objects without specifying their concrete classes. • Builder Separate the construction of a complex object from its representation, allowing the same construction process to create various representations. • Factory method Define an interface for creating a single object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses (dependency injection). • Prototype Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. • Singleton Ensure a class has only one instance, and provide a global point of access to it.
  • 16. Design Pattern Structural patterns • Adapter or Wrapper or Translator. Convert the interface of a class into another interface clients expect. An adapter lets classes work together that could not otherwise because of incompatible interfaces. The enterprise integration pattern equivalent is the translator. • Composite Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. • Decorator Attach additional responsibilities to an object dynamically keeping the same interface. Decorators provide a flexible alternative to subclassing for extending functionality. • Facade Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. • Module Group several related elements, such as classes, singletons, methods, globally used, into a single conceptual entity. • Front Controller The pattern relates to the design of Web applications. It provides a centralized entry point for handling requests.
  • 17. Design Pattern Behavioral patterns • Blackboard Generalized observer, which allows multiple readers and writers. Communicates information system-wide. • Interpreter Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language. • Iterator Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. • Null object Avoid null references by providing a default object. • Strategy Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it. • Template method Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure. • State Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
  • 18. Design Pattern Concurrency patterns • Active Object Decouples method execution from method invocation that reside in their own thread of control. The goal is to introduce concurrency, by using asynchronous method invocation and a scheduler for handling requests. • Balking Only execute an action on an object when the object is in a particular state. • Messaging design pattern (MDP) Allows the interchange of information (i.e. messages) between components and applications. • Monitor object An object whose methods are subject to mutual exclusion, thus preventing multiple objects from erroneously trying to use it at the same time. • Event-based asynchronous Addresses problems with the asynchronous pattern that occur in multithreaded programs. • Join Join-patterns provides a way to write concurrent, parallel and distributed programs by message passing. Compared to the use of threads and locks, this is a high level programming model. • Lock One thread puts a "lock" on a resource, preventing other threads from accessing or modifying it.
  • 19. Last But Not Least Characteristics of a bad Programmer • The StackOverflow bot • The I-am-not-a-tester • The I-hate-documentation • The ugly: My code works, but: • Have variables named x, flag, str, arr, etc. • -Most of what I write is in one giant method. • -There is no indentation. • -No consistent coding convention or style. • -Global variables spewed all over the place, etc. • The short-term investor • He codes. He deploys. He moves on. No attempt to learn the problem. No interest in the domain. Just give this guy a piece of code, he will slog on it overnight and hand it over. • The protester • “I didn’t do this”. • “This looks bad”. • “Not my problem”. • “This isn’t related really to my fix, but someone way over there made a mistake”. • “I hate this (loop this sentence 10 times a day)”. • “I can’t fix this, get the person who made this code to fix it”. • The dictator : My way or the highway • The overcautious • The careless • Forgets to take a backup, snapshots, has multiple working directories of code. • The lazy pseudo-hacker • Just Use tricks to make it work for now.
  • 20. Thanks Guys For wasting your precious time with me.