Code Review Checklist: How far is a code review going? "Metrics measure the design of code after it has been written, a Review proofs it and Refactoring improves code."
In this paper a document structure is shown and tips for a code review.
Some checks fits with your existing tools and simply raises a hand when the quality or security of your codebase is impaired.
Woxa Technologies have great industrial exoerts in java field they work on the live projects with students they are not teacher they are industrial trainer.
for more information 8471003400
Have you ever wondered how to speed up your code in Python? This presentation will show you how to start. I will begin with a guide how to locate performance bottlenecks and then give you some tips how to speed up your code. Also I would like to discuss how to avoid premature optimization as it may be ‘the root of all evil’ (at least according to D. Knuth).
Woxa Technologies have great industrial exoerts in java field they work on the live projects with students they are not teacher they are industrial trainer.
for more information 8471003400
Have you ever wondered how to speed up your code in Python? This presentation will show you how to start. I will begin with a guide how to locate performance bottlenecks and then give you some tips how to speed up your code. Also I would like to discuss how to avoid premature optimization as it may be ‘the root of all evil’ (at least according to D. Knuth).
Using static code analysis tools and detecting and fixing identified issues is very important in order to improve the quality and security of the code baseline.
CodeChecker (https://github.com/Ericsson/codechecker ) is an open source analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy.
It provides a number of additional features:
- Good visualization of problems in the code
- Overview of results for the whole product
- Filtering
- Cross translational unit analysis and statistical checkers support
- Suppression handling
- And many others...
These features simplify the follow up of results and make it more efficient.
In the video, an overview of features and capabilities of CodeChecker is demonstrated as well as a description and recommendation of how to introduce new tools.
Recording of the demo: https://youtu.be/sQ2Qj0kHoRY published in C++ Dublin User group https://www.youtube.com/channel/UCZ4UNE_1IMUFfAhcdq7CMOg/
Useful links:
open source project: https://github.com/Ericsson/codechecker
http://codechecker-demo.eastus.cloudapp.azure.com/login.html#
demo/demo
https://codechecker.readthedocs.io/en/latest/
http://clang-analyzer.llvm.org/available_checks.html
http://clang.llvm.org/extra/clang-tidy/checks/list.html
Other related videos about Clang Static Analyzer and CodeChecker that goes a bit more deeply into how Clang Static Analyzer works:
Clang Static Analysis - Meeting C++ 2016 Gabor Horvath
https://www.youtube.com/watch?v=UcxF6CVueDM
CppCon 2016: Gabor Horvath “Make Friends with the Clang Static Analysis Tools"
https://www.youtube.com/watch?v=AQF6hjLKsnM
maXbox Starter 43 Work with Code Metrics ISO StandardMax Kleiner
Today we step through optimize your code with metrics and some style guide conventions. You cannot improve what you don’t measure and what you don’t measure, you cannot prove. A tool can be great for code quality but also provides a mechanism for extending your functions and quality with checks and tests.
A Web Framework that shortens the Time it takes to develop software in at least an Order of Magnitude. while also tremendously minimizing Effort Pain, Time waste, Complexity, Cost of change & more
How Skroutz S.A. utilizes Deep Learning and Machine Learning techniques to efficiently serve product categorization! Based on my talk at Athens PyData meetup!
The global PyData network promotes discussion of best practices, new approaches, and emerging technologies for data management, processing, analytics, and visualization
A brief introduction about the art of unit test, how to test a class, mock a collaborator and use a fake database. TDD is introduced. Code for exercises is available on github along with a detailed explanation. Examples and exercises are written in Java.
Some of the most common and easy-to-calculate/easy-to-measure code metrics. Understanding these can help you make your code better: avoiding code rot and writing maintainable code all starts here. Content is created for C# .net, however, the underlying principles apply to other languages/frameworks as well.
Rails is a great Ruby-based framework for producing web sites quickly and effectively. Here are a bunch of tips and best practices aimed at the Ruby newbie.
Scripting experts from Inductive Automation cover general best practices that will help you add flexibility and customization to HMI, SCADA, IIoT, and other industrial applications. Some specific tips about using scripting in the Ignition platform will be included as well.
In this webinar, learn more about:
• Common scripting pitfalls and how to avoid them
• The best programming languages to use
• Things to consider before using scripting
• How scripting environments work
• Scripting timesavers
• And more
Scripting experts from Inductive Automation cover general best practices that will help you add flexibility and customization to HMI, SCADA, IIoT, and other industrial applications. Some specific tips about using scripting in the Ignition platform will be included as well.
In this webinar, learn more about:
• Common scripting pitfalls and how to avoid them
• The best programming languages to use
• Things to consider before using scripting
• How scripting environments work
• Scripting timesavers
• And more
In the last sessions we have seen that P4D (Python 4 Delphi) is powerful enough to offer components, Python packages or libraries in Delphi or Lazarus (FPC). This time we go the other way of usage and integration; how does the Python or web world in the shell benefit from the VCL components as GUI controls. We create a Python extension module from Delphi classes, packages or functions. Building Delphi’s VCL library as a specific Python module in a console or editor and launching a complete Windows GUI from a script can be the start of a long journey.
The flood of Open APIs is now so blatant that we take a closer look at some basics and principles. Of course, the best way to understand how APIs work is to try them. While most APIs require access via API keys or have complicated authentication and authorization methods, there are also open APIs with no requirements or licenses whatsoever. This is especially useful for beginners as we can start exploring different APIs right away. It’s also useful for web developers who want easy access to a sample dataset for their app; e.g. most weather apps get their weather forecast data from a weather API instead of building weather stations themselves.
Faker is a Python library that generates fake data. Fake data is often used for testing or filling databases with some dummy data. Faker is heavily inspired by PHP's Faker, Perl's Data::Faker, and by Ruby's Faker.
Many of the applications and organizations provide avatar features. Finally, synthetic datasets can minimize privacy concerns. Attempts to anonymize data can be ineffective, as even if sensitive/identifying variables are removed from the dataset
Python for Delphi (P4D) is a set of free components that wrap up the Python DLL into Delphi and Lazarus (FPC). They let you easily execute Python scripts, create new Python modules and new Python types. You can create Python extensions as DLLs and much more like scripting. P4D provides different levels of functionality: Low-level access to the python API High-level bi-directional interaction with Python Access to Python objects using Delphi custom variants (VarPyth.pas).
Python for Delphi (P4D) is a set of free components that wrap up the Python DLL into Delphi and Lazarus (FPC). They let you easily execute Python scripts, create new Python modules and new Python types. You can create Python extensions as DLLs and much more like scripting. P4D provides different levels of functionality:
Low-level access to the python API
High-level bi-directional interaction with Python
Access to Python objects using Delphi custom variants (VarPyth.pas)
Wrapping of Delphi objects for use in python scripts using RTTI (WrapDelphi.pas)
Creating python extension modules with Delphi classes and functions
Generate Scripts in maXbox from Python Installation
With the following report I show how to host and execute a deep learning project on a cloud. The cloud is hosted by google Colab and enables working and testing in teams. Lazarus and FreePascal is also being built in colab and the deep learning network is compiled and trained too in a Jupyter notebook with Python scripts.
The portable pixmap format(PPM), the portable graymap format(PGM) and portable bitmap format(PBM) are image file formats designed to be easily exchanged between platforms. They are also sometimes referred collectively as the portable anymap format(PNM). These formats are a convenient (simple) method of saving image data. And the format is not even limited to graphics, its definition allowing it to be used for arbitrary three-dimensional matrices or cubes of unsigned integers.
This tutor puts a trip to the kingdom of object recognition with computer vision knowledge and an image classifier.
Object detection has been witnessing a rapid revolutionary change in some fields of computer vision. Its involvement in the combination of object classification
as well as object recognition makes it one of the most challenging topics in the domain of machine learning & vision.
How can we visualize data in machine learning with VS Code? This is a C# wrapper for the GraphViz graph generator for dotnet core. Further bindings for Python GraphViz are shown and exports to MS Power BI all in MS Visual Code, Jupyter and dotnet core.
K-CAI NEURAL API is a Keras based neural network API for machine learning that will allow you to prototype with a lots of possibilities of Tensorflow! Python, Free Pascal and Delphi together in Google Colab, Git or the Community Edition.
Software is changing the world. CGC is a Common Gateway Coding as the name says, it is a "common" language approach for almost everything. I want to show how a multi-language approach to infrastructure as code using general purpose programming languages lets cloud engineers and code producers unlocking the same software engineering techniques commonly used for applications.
Open LDAP as A directory serviceis a system for storing and retrieving information in a tree-like structure with the following key properties:
Optimized for reading Distributed storage model Extensible data storage types Advanced search capabilities Consistent replication possibilities
They are a block of code plus the bindings to the environment they came from (RagusaIdiom).
Closures are reusable blocks of code that capture the environment and can be passed around as method arguments for immediate or deferred execution.
This tutor explains a solution to attach a console to your app. Basically we want an app to have two modes, a GUI mode and a non-GUI mode for any humans and robots. A NoGUI app provides a mechanism for storage and retrieval of data and functions in means other than the normal GUI used in operating systems.
Introduction to use machine learning in python and pascal to do such a thing like train prime numbers when there are algorithms in place to determine prime numbers. See a dataframe, feature extracting and a few plots to re-search for another hot experiment to predict prime numbers.
This tutor shows the train and test set split with binary classifying, clustering and 3D plots and discuss a probability density function in scikit-learn on synthetic datasets. The dataset is very simple as a reference of understanding.
This tutor shows the train and test set split with histogram and a probability density function in scikit-learn on synthetic datasets. The dataset is very simple as a reference of understanding.
In this article you will learn hot to use tensorflow Softmax Classifier estimator to classify MNIST dataset in one script.
This paper introduces also the basic idea of a artificial neural network.
The term “machine learning” is used to describe one kind of “artificial intelligence” (AI) where a machine is able to learn and adapt through its own experience. We crawled and collected 30 top overview diagrams which shows the topic of methods, algorithms and concepts.
TensorFlow is a Python-friendly open source library for numerical computation that makes machine learning faster and easier and ease the process of acquiring data, training models, serving predictions, and refining future results.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
Understanding Inductive Bias in Machine LearningSUTEJAS
This presentation explores the concept of inductive bias in machine learning. It explains how algorithms come with built-in assumptions and preferences that guide the learning process. You'll learn about the different types of inductive bias and how they can impact the performance and generalizability of machine learning models.
The presentation also covers the positive and negative aspects of inductive bias, along with strategies for mitigating potential drawbacks. We'll explore examples of how bias manifests in algorithms like neural networks and decision trees.
By understanding inductive bias, you can gain valuable insights into how machine learning models work and make informed decisions when building and deploying them.
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
Water billing management system project report.pdfKamal Acharya
Our project entitled “Water Billing Management System” aims is to generate Water bill with all the charges and penalty. Manual system that is employed is extremely laborious and quite inadequate. It only makes the process more difficult and hard.
The aim of our project is to develop a system that is meant to partially computerize the work performed in the Water Board like generating monthly Water bill, record of consuming unit of water, store record of the customer and previous unpaid record.
We used HTML/PHP as front end and MYSQL as back end for developing our project. HTML is primarily a visual design environment. We can create a android application by designing the form and that make up the user interface. Adding android application code to the form and the objects such as buttons and text boxes on them and adding any required support code in additional modular.
MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software. It is a stable ,reliable and the powerful solution with the advanced features and advantages which are as follows: Data Security.MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
HEAP SORT ILLUSTRATED WITH HEAPIFY, BUILD HEAP FOR DYNAMIC ARRAYS.
Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar to the selection sort where we first find the minimum element and place the minimum element at the beginning. Repeat the same process for the remaining elements.
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...ssuser7dcef0
Power plants release a large amount of water vapor into the
atmosphere through the stack. The flue gas can be a potential
source for obtaining much needed cooling water for a power
plant. If a power plant could recover and reuse a portion of this
moisture, it could reduce its total cooling water intake
requirement. One of the most practical way to recover water
from flue gas is to use a condensing heat exchanger. The power
plant could also recover latent heat due to condensation as well
as sensible heat due to lowering the flue gas exit temperature.
Additionally, harmful acids released from the stack can be
reduced in a condensing heat exchanger by acid condensation. reduced in a condensing heat exchanger by acid condensation.
Condensation of vapors in flue gas is a complicated
phenomenon since heat and mass transfer of water vapor and
various acids simultaneously occur in the presence of noncondensable
gases such as nitrogen and oxygen. Design of a
condenser depends on the knowledge and understanding of the
heat and mass transfer processes. A computer program for
numerical simulations of water (H2O) and sulfuric acid (H2SO4)
condensation in a flue gas condensing heat exchanger was
developed using MATLAB. Governing equations based on
mass and energy balances for the system were derived to
predict variables such as flue gas exit temperature, cooling
water outlet temperature, mole fraction and condensation rates
of water and sulfuric acid vapors. The equations were solved
using an iterative solution technique with calculations of heat
and mass transfer coefficients and physical properties.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesChristina Lin
Traditionally, dealing with real-time data pipelines has involved significant overhead, even for straightforward tasks like data transformation or masking. However, in this talk, we’ll venture into the dynamic realm of WebAssembly (WASM) and discover how it can revolutionize the creation of stateless streaming pipelines within a Kafka (Redpanda) broker. These pipelines are adept at managing low-latency, high-data-volume scenarios.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
1. Code Review Checklist
How far is a code review going?
“Metrics measure the design of code after it
has been written, a Review proofs it and
Refactoring improves code.”
2. 2
The Problem is
• That the problem of source code smells is
additive (new bugs arise but the old ones stay)
• Das kann bei uns nicht passieren! – wieso ist
das denn passiert?
• Management is arrogance and developers are
too proud to admit mistakes
• Programmers don't die, they just GOSUB
without RETURN.
3. 3
Improve the Situation Agenda
• Check your Documents with UML API?
• A Docu Structure to the 5 Top Level Metrics
• Back to Source Code Bugs & Smells
• Improve your Code (Metric Based Refactoring)
• Optimisation and Tools
4. 4
API Layers to Structure
Metrics are for detecting bad code entities
• Function calls for type
• Class blocks for object
• Module components for file
• Library package for directory
• Framework deployment for device
UEB: 640_API_LayerDetection_EKON23.TXT
5. 5
API Layers to UML!
Metrics are for detecting bad code entities
• Function calls for Sequence Diagram
• Class blocks for Class Diagram
• Module components for Com.Diagram
• Library package for Package Diagram
• Framework deployment for Dep.D
http://www.kleiner.ch/kleiner/UML_bigpicture.pdf
6. 6
What‘s API Layering?
Bad Coordination possible
• Function with Threads
• Class Access on objects with Null Pointer
• Module Bad Open/Close of Input/Output
Streams or I/O Connections component
• Package return values or package namespace
• Framework in deployment code
• Docker Composer Access of Container image
constructor on non initialized vars
7. 7
Metrics deal with
Bad Structure (how cohesion & coupling)
• General Code Size (in module)
• Cohesion (in classes and inheritance)
• Complexity
• Coupling (between classes or units)
• Cyclic Dependency, Declare+Definition, ACD-Metric
• Interfaces or Packages (design & runtime)
• Static, Public, Private (inheritance or delegate)
UEB: 10_pas_oodesign_solution.txt
8. 8
Finally you can measure:
Bad Habit (no naming convention, no coverage)
Duplicated, dead code (side effects), bugs & smells
Long Methods (to much code), missing layering
Temporary Fields (confusion), comments or docs
Long Parameter List (Object is missing)
Data Classes (no methods)
• Large Class with too many delegating methods
In a Kiviat Chart you get a Best Practices Circle!
UEB: 33_pas_cipher_file_1.txt
11. 11
Review Doc Structure II
• Reliability means less Bugs
The degree to which a system or component performs specified functions under specified conditions
for a specified period of time.
• Security means less Vulnerability
The degree of protection of information and data so that unauthorized persons or systems cannot
read or modify them and authorized persons or systems are not denied access to them.
• Maintainability means less Code Smells
The degree of effectiveness and efficiency with which the product can be modified in the sense of
measured code smells which a non compliant to coding conventions or standards.
• Operability means less Complexity
The degree to which the product has attributes that enable it to be understood, learned, used and
attractive to the user, when used under specified conditions.
• Functionality means more Coverage and Size
It measures the minimum number of test cases required for full test coverage.
13. 13
When and why Metrics ?
Before a Code Review
By changes of a release
Redesign with UML (Patterns or Profiles)
Law of Demeter not passed
Bad Testability (FAT or SAT)
• Work on little steps at a time
• Modify not only structure but also code format
14. 14
Some Kind of wonderful ?
• statusbar1.simpletext
• simplepanel:= true!
• TLinarBitmap = TLinearBitmap; //Spelling bug
• aus Win32.VCL.Dialogs.pas
• WndProcPtrAtom: TAtom = 0;
• aus indy: self.sender!
• procedure TIdMessageSender_W(Self: TIdMessage;
const T: TIdEmailAddressItem);
• begin Self.Sender := T; end;
UEB: 8_pas_verwechselt.txt
15. 15
Metric/Review Checklist
1. Standards - are the Pascal software standards for
name conventions being followed?
2. Are all program headers completed?
3. Are changes commented appropriately?
4. Are release notes Clear? Complete?
5. Installation Issues, Licenses, Certs. Are there any?
6. Version Control, Are output products clear?
7. Test Instructions - Are they any? Complete?
8. "Die andere Seite, sehr dunkel sie ist" - "Yoda, halt's Maul und iß
Deinen Toast!"
16. 16
Top Ten Metrics
1. VOD Violation of Law of Demeter
2. Halstead NOpmd (Operands/Operators)
3. DAC (Data Abstraction Coupling)(Too many
responsibilities or references in the field)
4. CC (Complexity Report), McCabe cyclomatic
complexity, Decision Points)
5. CBO (Coupling between Objects) Modularity
17. 17
Top Ten II
6. PUR (Package Usage Ratio) access information
in a package from outside
7. DD Dependency Dispersion (SS, Shotgun Surgery
(Little changes distributed over too many
objects or procedures patterns missed))
8. CR Comment Relation
9. MDC (Module Design Complexity (Class with too
many delegating methods)
10. NORM (remote methods called (Missing
polymorphism))
18. 18
Law of Demeter
1. [M1] an Objekt O selbst
Bsp.: self.initChart(vdata);
2. [M2] an Objekte, die als Parameter in der Nachricht
m vorkommen
Bsp.: O.acceptmemberVisitor(visitor)
visitor.visitElementChartData;
3. [M3] an Objekte, die O als Reaktion auf m erstellt
Bsp.: visitor:= TChartVisitor.create(cData, madata);
4. [M4] an Objekte, auf die O direkt mit einem Member
zugreifen kann
Bsp.: O.Ctnr:= visitor.TotalStatistic
20. 20
DAC or Modules of Classes
Large classes with to many references
• More than seven or eight variables
• More than fifty methods
• You probably need to break up the class in
Components (Strategy, Composite, Decorator)
TWebModule1 = class(TWebModule)
HTTPSoapDispatcher1: THTTPSoapDispatcher;
HTTPSoapPascalInvoker1: THTTPSoapPascalInvoker;
WSDLHTMLPublish1: TWSDLHTMLPublish;
DataSetTableProducer1: TDataSetTableProducer;
21. 21
CC
• Check Complexity
function IsInteger(TestThis: string): Boolean;
begin
try
StrToInt(TestThis);
except
on EConvertError do
result:= False;
else
result:= True;
end;
end; Ueb: 164_code_reviews.txt
23. 23
DD – Test keywords knowledge
Procedure CopyRecord(const SourceTable, DestTable:
TTable);
var i: Word;
begin
DestTable.Append;
For i:= 0 to SourceTable.FieldCount - 1 do
DestTable.Fields[i].Assign(SourceTable.Fields[i]);
DestTable.Post;
end;
24. 24
DD – use small procedures
Procedure CopyRecord(const SourceTable, DestTable:
TTable);
var i: Word;
begin
DestTable.Append;
For i:= 0 to SourceTable.FieldCount - 1 do
DestTable.Fields[i].Assign(SourceTable.Fields[i]);
DestTable.Post;
end;
25. 25
Why is Refactoring important?
• Only defense against software decay.
• Often needed to fix reusability bugs.
• Lets you add patterns or templates after you
have written a program;
• Lets you transform program into framework.
• Estimation of the value (capital) of code!
• Necessary for beautiful software.
26. 26
Refactoring Process
The act of serialize the process:
Build unit test
Refactor and test the code (iterative!)
Check with Analyzer or another tool
Build the code
Running all unit tests
Generating the documentation
Deploying to a target machine
Performing a “smoke test” (just compile)
27. 27
Let‘s practice
• 1
• 11
• 21
• 1211
• 111221
• 312211
• ??? Try to find the next pattern, look for
a rule or logic behind !
28. 28
Before R.
function runString(Vshow: string): string;
var i: byte;
Rword, tmpStr: string;
cntr, nCount: integer;
begin
cntr:=1; nCount:=0;
Rword:=''; //initialize
tmpStr:=Vshow; // input last result
for i:= 1 to length(tmpStr) do begin
if i= length(tmpstr) then begin
if (tmpStr[i-1]=tmpStr[i]) then cntr:= cntr +1;
if cntr = 1 then nCount:= cntr
Rword:= Rword + intToStr(ncount) + tmpStr[i]
end else
if (tmpStr[i]=tmpStr[i+1]) then begin
cntr:= cntr +1;
nCount:= cntr;
end else begin
if cntr = 1 then cntr:=1 else cntr:=1; //reinit counter!
Rword:= Rword + intToStr(ncount) + tmpStr[i] //+ last char(tmpStr)
end;
end; // end for loop
result:=Rword;
end; UEB: 9_pas_umlrunner.txt
29. 29
After R.
function charCounter(instr: string): string;
var i, cntr: integer; Rword: string;
begin
cntr:= 1;
Rword:=' ';
for i:= 1 to length(instr) do begin
//last number in line
if i= length(instr) then
concatChars()
else
if (instr[i]=instr[i+1]) then cntr:= cntr +1
else begin
concatChars()
//reinit counter!
cntr:= 1;
end;
end; //for
result:= Rword;
end;
UEB: 12_pas_umlrunner_solution.txt
30. 30
Refactoring Methods
Einheit Refactoring Funktion Beschreibung
Package Rename Package Rename of Packages
Class Move Method Remove of Methods
Class Extract Superclass Aus Methoden, Eigenschaften eine
Oberklasse erzeugen und verwenden
Class Introduce Parameter Replace of Expression w. Methodparameter
Class Extract Method Heraustrennen einer Codepassage
Interface Extract Interface Aus Methoden ein Interface erzeugen
Interface Use Interface Erzeuge Referenzen auf Klasse
Component Replace Inheritance
with Delegation
Ersetze vererbte Methoden durch Delegation
in innere Klasse
Class Encapsulate Fields Getter- and Setter capsulate
Model Safe Delete Delete a Class with References