This document discusses techniques for working with legacy code, including sprout method, wrap method, and wrap class. Sprout method involves extracting part of an existing method into a new method. Wrap method surrounds an existing method with new code. Wrap class creates a new class that delegates to the original class, allowing new behavior to be added. The techniques allow new functionality to be added to legacy code in a way that does not disrupt existing behavior and allows the new code to be tested independently.
Part of the software developer job is to find new and better ways to solve problems. Writing code using his/her wits, intelligent and creativity.
However, sometimes being too clever can lead to hard to track bugs, maintainability issues and impossible to understand code. Is all cleverly written code good code, or is it a problem just waiting to happen?
In this session, I will show you real world examples of cleverly written code. And show you how we can use clean code principles, refactoring and design patterns, to transform that code from clever code to good code, code one that your peers - and future self - would thank you for writing.
Unit testing patterns for concurrent codeDror Helper
Getting started with unit testing is not hard, the only problem is that most programs are more than a simple calculator with two parameters and a returns value that is easy to verify. Writing unit tests for multi-threaded code is harder still. Over the years I discovered useful patterns that helped me to test multi-threaded and asynchronous code and enabled the creation of deterministic, simple and robust unit tests. Come learn how to test code that uses concurrency and parallelism – so that the excuses of not writing unit tests for such code would become as obsolete as a single core processors.
Fun with Lambdas: C++14 Style (part 1)Sumant Tambe
If virtual functions in C++ imply design patterns, then C++ lambdas imply what? What does it really mean to have lambdas in C++? Frankly, I don't know but I've a hunch: It's BIG.
Just like virtual functions open doors to the OO paradigm, lambdas open doors to a different paradigm--the functional paradigm. This talk is not a praise of functional programming or some elusive lambda-based library. (Although, I'll mention one briefly that tops my list these days.) Instead, the goal is to have fun while working our way through some mind-bending examples of C++14 lambdas. Beware, your brain will hurt! Bring your laptop and code the examples right along because that may be the fastest way to answer the quiz.
Part of the software developer job is to find new and better ways to solve problems. Writing code using his/her wits, intelligent and creativity.
However, sometimes being too clever can lead to hard to track bugs, maintainability issues and impossible to understand code. Is all cleverly written code good code, or is it a problem just waiting to happen?
In this session, I will show you real world examples of cleverly written code. And show you how we can use clean code principles, refactoring and design patterns, to transform that code from clever code to good code, code one that your peers - and future self - would thank you for writing.
Unit testing patterns for concurrent codeDror Helper
Getting started with unit testing is not hard, the only problem is that most programs are more than a simple calculator with two parameters and a returns value that is easy to verify. Writing unit tests for multi-threaded code is harder still. Over the years I discovered useful patterns that helped me to test multi-threaded and asynchronous code and enabled the creation of deterministic, simple and robust unit tests. Come learn how to test code that uses concurrency and parallelism – so that the excuses of not writing unit tests for such code would become as obsolete as a single core processors.
Fun with Lambdas: C++14 Style (part 1)Sumant Tambe
If virtual functions in C++ imply design patterns, then C++ lambdas imply what? What does it really mean to have lambdas in C++? Frankly, I don't know but I've a hunch: It's BIG.
Just like virtual functions open doors to the OO paradigm, lambdas open doors to a different paradigm--the functional paradigm. This talk is not a praise of functional programming or some elusive lambda-based library. (Although, I'll mention one briefly that tops my list these days.) Instead, the goal is to have fun while working our way through some mind-bending examples of C++14 lambdas. Beware, your brain will hurt! Bring your laptop and code the examples right along because that may be the fastest way to answer the quiz.
A small introduction on the C++14 improved static introspection of the IOD library and the C++14 web framework Silicon.
https://github.com/matt-42/silicon
https://github.com/matt-42/iod
Скомпилировалось — значит работает. К сожалению это выражение не про typescript. Кажется, что количество рантайм ошибок спровоцированных несоответствием типов должно стать меньше, однако компилятор ts не помогает разработчику писать качественный код, а наоборот поощряет использование грязных хаков. Филипп Сапронов рассказывает, как прекратить войну с компилятором и писать более надёжный код, используя всю мощь системы типов. Доклад будет интересен тем, кому ts кажется простым или наоборот сложным, а также тем, кто хочет научится понимать код тайпингов таких библиотек как lodash.
The secret unit testing tools no one ever told you aboutDror Helper
There are more to unit testing than using a unit testing framework - in order to succeed you want to use the right tools for the job. There are a few tools that almost no one talks about - some enabling creating of top-notch, robust unit tests. Some will help you run your tests better and faster. In this session I'll explain about the inevitable maintainability problems developers face when writing and maintaining huge unit testing suits and how unit level BDD, AutoMocking, and Continuous Execution can help take control over your tests.
A small introduction on the C++14 improved static introspection of the IOD library and the C++14 web framework Silicon.
https://github.com/matt-42/silicon
https://github.com/matt-42/iod
Скомпилировалось — значит работает. К сожалению это выражение не про typescript. Кажется, что количество рантайм ошибок спровоцированных несоответствием типов должно стать меньше, однако компилятор ts не помогает разработчику писать качественный код, а наоборот поощряет использование грязных хаков. Филипп Сапронов рассказывает, как прекратить войну с компилятором и писать более надёжный код, используя всю мощь системы типов. Доклад будет интересен тем, кому ts кажется простым или наоборот сложным, а также тем, кто хочет научится понимать код тайпингов таких библиотек как lodash.
The secret unit testing tools no one ever told you aboutDror Helper
There are more to unit testing than using a unit testing framework - in order to succeed you want to use the right tools for the job. There are a few tools that almost no one talks about - some enabling creating of top-notch, robust unit tests. Some will help you run your tests better and faster. In this session I'll explain about the inevitable maintainability problems developers face when writing and maintaining huge unit testing suits and how unit level BDD, AutoMocking, and Continuous Execution can help take control over your tests.
JDD 2016 - Sebastian Malaca - You Dont Need Unit TestsPROIDEA
How often did you hear developers who were proving quality of their application’s code by sharing information about really high coverage and a huge number of unit tests? How often did you hear how unit tests can make your life easier. How having unit tests makes it possible to introduce changes and make refactoring safier? Do you believe in it? What’s your experience?
I will show you why all of those “proofs” are invalid and wrong. I will show you the false impression of feeling safe in those dangerous places where your code is covered only with tones of unit tests.
But it won’t be all. I won’t leave you alone in this place. I will tell you what you can do to make things better.
I will show you the difference between coverage and quality. Between unit tests and safety.
Workshop slides from the Alt.Net Seattle 2011 workshop. Presented by Wes Dyer and Ryan Riley. Get the slides and the workshop code at http://rxworkshop.codeplex.com/
You may be hearing a lot of buzz around functional programming. For example, Java 8 recently introduced new features (lambda expressions and method references) and APIs (Streams, Optional and CompletableFutures) inspired from functional ideas such as first-class functions, composition and immutability.
However, what does this mean for my existing codebase?
In this talk we show how you can refactor your traditional object-oriented Java to using FP features and APIs from Java 8 in a beneficial manner.
We will discuss:
- How to adapt to requirement changes using first-class functions
- How you can enhance code reusability using currying
- How you can make your code more robust by favouring immutability over mutability
- How you can design better APIs and reduce unintended null pointer exceptions using an optional data type"
Similar to Working effectively with legacy code (20)
Lean Startup has revolutionized the startup movement. Startup world is looking like more scientific these days. Because of that reason, a flood of people are trying their hands by opening new startups. However is there anything to learn from Lean Startup for enterprises using agile methodologies currently? This session tries to answer the same - ranging from how to use Lean Startup techniques as part of Agile Product Ownership to changing current Agile practices focused towards validated learning and customer development.
Take away for audience from this session is:
* How Agile Product Management can scientifically define, what exactly to build and why?
* How some important Agile practices need to improvise themselves based on Validated Learning and Customer Development concepts of Lean Startup?
* Instead of building the MVP or product features directly and finding out later that customers don't need them, finding that out sometimes without writing even a single line of code or with minimal investment and resources.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
2. Four Reasons to Change Software Adding a feature Fixing a bug Improving the design Optimizing resource usage
3. A Legacy Code Scenario What changes do we have to make? How will we know that we have done them correctly How will we know that we haven’t broken anything Avoiding change is a bad thing, but what is our alternative? Try harder. Hire more people
8. Legacy Code Dilemma When we change code, we should have tests in place. To put tests in place, we often have to change code. Use Primitivize Parameter and Extract Interface to remove these issues
11. Fake objects Support Real Tests public class FakeDisplay implements Display { private String lastLine = ""; public void showLine(String line) { lastLine = line; } public String getLastLine() { return lastLine; } } import junit.framework.*; public class SaleTest extends TestCase { public void testDisplayAnItem() { FakeDisplay display = new FakeDisplay(); Sale sale = new Sale(display); sale.scan("1"); assertEquals("Milk $3.99", display.getLastLine()); } }
13. Object Seam class CAsyncSslRec { ... virtual void PostReceiveError(UINT type, UINT errorcode); ... }; class TestingAsyncSslRec : public CAsyncSslRec { virtual void PostReceiveError(UINT type, UINT errorcode) { } };
14. Seam Types Preprocessing Seams Link Seams : static linking in C/C++/Flex and dynamic linking in Java Object Seams
15. I Don't Have Much Time and I Have to Change It Sprout Method Sprout Class Wrap Method Wrap Class
16. Sprout Method public class TransactionGate { public void postEntries(List entries) { for (Iterator it = entries.iterator(); it.hasNext(); ) { Entry entry = (Entry)it.next(); entry.postDate(); } transactionBundle.getListManager().add(entries); } ... }
17. Sprout Method public class TransactionGate { public void postEntries(List entries) { List entriesToAdd = new LinkedList(); for (Iterator it = entries.iterator(); it.hasNext(); ) { Entry entry = (Entry)it.next(); if (!transactionBundle.getListManager().hasEntry(entry) { entry.postDate(); entriesToAdd.add(entry); } } transactionBundle.getListManager().add(entriesToAdd); } ... }
18. Sprout Method public class TransactionGate { ... List uniqueEntries(List entries) { List result = new ArrayList(); for (Iterator it = entries.iterator(); it.hasNext(); ) { Entry entry = (Entry)it.next(); if (!transactionBundle.getListManager().hasEntry(entry) { result.add(entry); } } return result; } ... } public class TransactionGate { ... public void postEntries(List entries) { List entriesToAdd = uniqueEntries(entries); for (Iterator it = entriesToAdd.iterator(); it.hasNext(); ) { Entry entry = (Entry)it.next(); entry.postDate(); } transactionBundle.getListManager().add(entriesToAdd); } ... }
20. Wrap Method public class Employee { ... public void pay() { Money amount = new Money(); for (Iterator it = timecards.iterator(); it.hasNext(); ) { Timecard card = (Timecard)it.next(); if (payPeriod.contains(date)) { amount.add(card.getHours() * payRate); } } payDispatcher.pay(this, date, amount); } }
21. Wrap Method public class Employee { private void dispatchPayment() { Money amount = new Money(); for (Iterator it = timecards.iterator(); it.hasNext(); ) { Timecard card = (Timecard)it.next(); if (payPeriod.contains(date)) { amount.add(card.getHours() * payRate); } } payDispatcher.pay(this, date, amount); } public void pay() { logPayment(); dispatchPayment(); } private void logPayment() { ... } }
22. Wrap Method Advantages A good way of getting new, tested functionality into an application when we can't easily write tests for the calling code It explicitly makes the new functionality independent of existing functionality Disadvantages Can lead to poor names
23. Wrap Class class Employee { public void pay() { Money amount = new Money(); for (Iterator it = timecards.iterator(); it.hasNext(); ) { Timecard card = (Timecard)it.next(); if (payPeriod.contains(date)) { amount.add(card.getHours() * payRate); } } payDispatcher.pay(this, date, amount); } ... }
24. Wrap Class class LoggingEmployee extends Employee { public LoggingEmployee(Employee e) { employee = e; } public void pay() { logPayment(); employee.pay(); } private void logPayment() { ... } ... }
25. Wrap Class class LoggingPayDispatcher { private Employee e; public LoggingPayDispatcher(Employee e) { this.e = e; } public void pay() { employee.pay(); logPayment(); } private void logPayment() { ... } ... }
26. Wrap Class Able to add new behavior into a system without adding it to an existing class When there are many calls to the code you want to wrap, it often pays to move toward a decorator-ish wrapper If new behavior has to happen at couple of places, simple class wrapper is very useful
27. I Don't Have Much Time and I Have to Change It: Summary Use Sprout Method when the code you have in the existing method communicates a clear algorithm to the reader. Use Wrap Method when you think that the new feature you’re adding is as important as the work that was there before Use Wrap Class when the behavior that I want to add is completely independent
Editor's Notes
It seems nearly impossible to add behavior without changing it to some degree.Improving design – a series of small structural modifications, supported by tests to make the code easier to change.Optimization – functionality exactly the same but changing something else (usually time or memory)
Talk about a team policy where – if it’s not broke, don’t fix it. – Talk about problems it createsDifference between good and bad systems
Working with care – leads to using tools and techniques inefficiently
Use of safety netCovering software means covering with testsTesting to attempt to show correctnessVsTesting to detect change – tests as software vise – keep most of the behavior fixed and change only what you intend toRegression tests with or without writing tests – mention a story about doing the testing at the end
Other kinds of tests often masquerade as unit tests. A test is not a unit test if:It talks to a database.It communicates across a network.It touches the file system.You have to do special things to your environment (such as editing configuration files) to run it.
Servlet and DBConnection are two issuesPossible option – pass real db connection but how about servlet itself
Mock objects are advanced type of fakes.
A seam is a place where you can alter behavior in your program without editing in that place.
We need to add code to verify that none of the new entries are already in transactionBundle before we post their dates and add them.
Disadvantages: Giving up on the codeAdvantages: Separating new code from old code
Every time that we pay an employee, we have to update a file with the employee's name so that it can be sent off to some reporting softwareThe easiest way to do….is method
We create a method with the name of the original method and have it delegate to our old code
Use of decoratorToolController controller = new StepNotifyingController( new AlarmingController ( new ACMEController()), notifyees);