The document discusses test-driven development (TDD) and test-last development (TLD). It explains that TLD involves adding tests to existing legacy code, starting with the easiest parts to test, while not changing the production code. TDD involves writing tests before developing new code to specify requirements. The document demonstrates applying TLD and TDD to a registration form code example, separating testable logic into independent functions, adding tests, and refactoring to satisfy new requirements and prevent tests from breaking. Benefits of TLD and TDD mentioned include feeling less anxious and stressed.
A summary of clean code concepts and tips along with some examples and good practices.
These are the slides translated in English from my talk on Clean Code to my coworkers back then
- What's new in .NET Platform
- What's new in Visual Studio 2017
- What's new in C# 7.0: out variables, Tuples, Pattern Maching, ref locals and returns, Local Functions, More expression-bodied members, throw Expressions, Generalized async return types, Numeric literal syntax improvements
Rule 1: Follow a consistent coding standard
Rule 2: Name things properly, long variable and function names are allowed
Rule 3: Be expressive, write code as you speak and be optimally verbose
Rule 4: Max indent per method should be 2, in case of exceptions 3
Rule 5: Avoid creating god object and long methods
Rule 6: Keep the method in one place, inject the class and call it, DRY
Rule 7: Avoid in-line comments (comment with code), put comments in the method doc
More than a year has passed since we analyzed Notepad++ with PVS-Studio. We wanted to see how much better the PVS-Studio analyzer has become since then and which of the previous errors have been fixed in Notepad++.
The `Right way` of testing and refactoring is so ambiguous to put in the real world, Especially, Business situation.
Let's look in deep the testing and refactoring at the perspective of a developer who works for a business situation.
Скомпилировалось — значит работает. К сожалению это выражение не про typescript. Кажется, что количество рантайм ошибок спровоцированных несоответствием типов должно стать меньше, однако компилятор ts не помогает разработчику писать качественный код, а наоборот поощряет использование грязных хаков. Филипп Сапронов рассказывает, как прекратить войну с компилятором и писать более надёжный код, используя всю мощь системы типов. Доклад будет интересен тем, кому ts кажется простым или наоборот сложным, а также тем, кто хочет научится понимать код тайпингов таких библиотек как lodash.
A summary of clean code concepts and tips along with some examples and good practices.
These are the slides translated in English from my talk on Clean Code to my coworkers back then
- What's new in .NET Platform
- What's new in Visual Studio 2017
- What's new in C# 7.0: out variables, Tuples, Pattern Maching, ref locals and returns, Local Functions, More expression-bodied members, throw Expressions, Generalized async return types, Numeric literal syntax improvements
Rule 1: Follow a consistent coding standard
Rule 2: Name things properly, long variable and function names are allowed
Rule 3: Be expressive, write code as you speak and be optimally verbose
Rule 4: Max indent per method should be 2, in case of exceptions 3
Rule 5: Avoid creating god object and long methods
Rule 6: Keep the method in one place, inject the class and call it, DRY
Rule 7: Avoid in-line comments (comment with code), put comments in the method doc
More than a year has passed since we analyzed Notepad++ with PVS-Studio. We wanted to see how much better the PVS-Studio analyzer has become since then and which of the previous errors have been fixed in Notepad++.
The `Right way` of testing and refactoring is so ambiguous to put in the real world, Especially, Business situation.
Let's look in deep the testing and refactoring at the perspective of a developer who works for a business situation.
Скомпилировалось — значит работает. К сожалению это выражение не про typescript. Кажется, что количество рантайм ошибок спровоцированных несоответствием типов должно стать меньше, однако компилятор ts не помогает разработчику писать качественный код, а наоборот поощряет использование грязных хаков. Филипп Сапронов рассказывает, как прекратить войну с компилятором и писать более надёжный код, используя всю мощь системы типов. Доклад будет интересен тем, кому ts кажется простым или наоборот сложным, а также тем, кто хочет научится понимать код тайпингов таких библиотек как lodash.
We have successfully created and continue developing PVS-Studio analyzer for C/C++ languages. Over the time, it became clear that many of the diagnostics that we have implemented are not related to a specific programming language, so we decided to apply our experience to another programming language, namely C#. In this article, we are talking about the analysis of Code Contracts project by Microsoft done by our C# analyzer
About us
Author: Ted Piotrowski
Find me at: tpiotrowski@atlassian.com
Sample code: https://bitbucket.org/tpiotrowski/js-hcm
Presentation made for Javascript Ho Chi Minh City Meetup Group
You can find us at:
http://www.meetup.com/JavaScript-Ho-Chi-Minh-City/
https://www.facebook.com/JavaScriptHCMC
https://plus.google.com/u/0/communities/116105314977285194967
Unit Testing Front End JavaScript
with Yuri Takhteyev
Presented on September 18 2014 at
FITC's Web Unleashed Toronto 2014 Conference
More info at www.fitc.ca
Building complex software application can be made much easier with unit testing – a fact well established in back-end work but often overlooked on the front-end. Yuri Takhteyev will look at some of the tools and techniques for unit testing front end code, focusing on Mocha and Karma. Most of the examples will draw on AngularJS but the main ideas are applicable to other frameworks as well.
OBJECTIVE
Learn how to write unit tests for front-end code.
TARGET AUDIENCE
Front-end JavaScript developers not currently using unit testing or those experiencing difficulties with unit testing.
ASSUMED AUDIENCE KNOWLEDGE
Intermediate front-end JavaScript, no prior experience with front-end unit testing
FIVE THINGS AUDIENCE MEMBERS WILL LEARN
How unit testing benefits the developer
How to structure applications to make them testable
How to use Mocha and Karma in unit testing
How to mock dependencies (and why)
How to handle asynchronous code
Quick introduction into react and flux followed by a comparison of redux and alt flux frameworks and a simple hello world application implemented in each of them. Last two slides present a microservices approach to client side applications as one of approaches how to make transitions between frameworks easier.
페이스북 그룹 '소프트웨어캠퍼스' 커뮤니티의 서적 [밑바닥부터 시작하는 딥러닝]으로 진행한 스터디 발표 자료 입니다. 해당 자료는 챕터6 학습관련기술들에 대한 내용입니다. 외부 자료 상당 부분 사용하였으며 자료 출처는 슬라이드 뒷부분에 기재하였습니다.
프레젠테이션 페이지별 스크립트: https://www.slideshare.net/hyeseunglee6/ss-75889203
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
2. 01 Story about how I did
REAL Benefits I felt while doing TLD & TDD
▪ TLD (Test Last Development)
▪ TDD (Test Driven Development)
CONTENTS
02
3. In this presentation, “Test” means unit test only.
The language is JavaScript.
The test framework is Jest.
There's a React code, but it doesn't matter if you don't know it.
NOTICE
15. Code easy
to test
Code hard
to test
Production code
Pure function
External Dependency
Start with code that's already made easy to test
ex. utility, helper
16. // YY. M. DD.-> YYMMDD
export function formatDateForQueryString(dateString) {
const splitArray = dateString.split('.’);
splitArray.map((el, i, arr) => {
arr[i] = el.replace(/ /gi, '').length === 1 ? '0' + el : el;
});
return result.join('').replace(/ /gi, '');
}
Code easy
to test
Function that converts a string in format 'YY. M. DD. ' to a string in format 'YYMMDD'
// dateHelper.test.js
describe('formatDateForQueryString function', () => {
describe(‘converts a string in format “YY. M. DD.”', () => {
test(‘to a string in “YYMMDD”.', () => {
const actual = formatDateForQueryString('18. 1. 10.');
expect(actual).toBe('180110');
});
});
});
Don’t change production codes
17. // YY. M. DD.-> YYMMDD
export function formatDateForQueryString(dateString) {
const splitArray = dateString.split('.’);
splitArray.map((el, i, arr) => {
arr[i] = el.replace(/ /gi, '').length === 1 ? '0' + el : el;
});
return result.join('').replace(/ /gi, '');
}
Code easy
to test
// dateHelper.test.js
describe('formatDateForQueryString function', () => {
describe(‘converts a string in format “YY. M. DD.”', () => {
test(‘to a string in “YYMMDD”.', () => {
const actual = formatDateForQueryString('18. 1. 10.');
expect(actual).toBe('180110');
});
});
}); Don’t change the test codes
Function that converts a string in format 'YY. M. DD. ' to a string in format 'YYMMDD'
18. // YY. M. DD.-> YYMMDD
export function formatDateForQueryString(dateString) {
const splitArray = dateString.split('.’);
splitArray.map((el, i, arr) => {
arr[i] = el.replace(/ /gi, '').length === 1 ? '0' + el : el;
});
return result.join('').replace(/ /gi, '');
}
Code easy
to test
export function formatDateForQueryString(dateString) {
return `${dateString} `
.split('. ')
.map(x => (x.length === 1 ? `0${x}` : x))
.join('');
}
The refactoring should be limited to the extent that the test is not broken.
Refactor
19. Ex. Maybe almost?
Separate only those codes that are easy to test from those that are made difficult to test.
Code easy
to test
Code hard
to test
Production code
Parts include high-value business logic
Buggy code (current, not past)
Low coupling and complex logic*
Where can I find it?
*Low or no external dependency (independent environment)
and business logic is complex (Replace username to email, etc.)
21. class RegistrationFormContainer extends Component {
/ * (Omitted) Methods on modal behavior * /
handleSubmit = async () => {
const { validValues } = this.props.form;
const phone = validValues.phone
? '+82' + validValues.phone.slice(1)
: null;
const command = {
username: validValues.username || validValues.email,
email: validValues.email,
phone: phone,
};
try {
await postRegisterRequest(command);
this.closeModal();
} catch (err) {
Modal.error({ /* ... */ });
}
};
render() { /* ... */ }
}
}
Code hard
to test
* React code
This contains important business logic.
Why this code is difficult to test
• API request
• Different UI depending on the result of the response
Only separate testable parts
API request
31. 1. Adding tests to legacy code (+Refactor)
2. Develop new code with TDD.
HOW: Follows below cycle
Separate
as function
Refactor
Add test
code
WHAT: Codes easy to test
- Parts includes high-value business logic
- The spot where the bug was found (formerly X)
- Low coupling and complex logic
TLD
1. Add tests to code that is already easy to test.
2. Make your code easy to test, and then test.
TDD
- Where to add new features
34. /* ... */
describe('formatRegisterCommand function', () => {
test(‘does not throw error.', () => {
expect(formatRegisterCommand).not.toThrowError();
});
});
describe(‘whose agreement property should be', () => {
test('return false when any of the arguments are fal
=> {
const actual = formatRegisterCommand({
...param,
agreement: [true, true, false],
});
expect(actual).toBe(false);
});
});
/* ... */
UTF-8 LF JavaScript React Prettier:
formatRegisterCommand.js formatRegisterCommand.test.js
function formatRegisterCommand(source = {}) {
const { username, email, phone } = source;
if (source.agreement.some(agree => !agree)) {
return false;
}
return {
username: username || email,
email,
phone: phone ? `+82${phone.slice(1)}` : null,
};
}
export default formatRegisterCommand;
if (source.agreement.some(agree => !agree)) {
return false;
}
FAIL src/business/formatRegisterCommand.test.js
● formatRegisterCommand function › does not throw error.
expect(function).not.toThrowError()
Expected the function not to throw an error.
Instead, it threw:
TypeError: Cannot read property 'some' of undefined
at formatRegisterCommand (src/business/formatRegisterCommand.js:9:17)
/* ... */
formatRegisterCommand function
✓ does not throw error.
return command
UTF-8 LF JavaScript React Prettier:
35. The test code makes me to find the
code smell pretty often.
Things I really felt while doing TEST.
Improve the design of code
36. PASS src/business/formatRegisterCommand.test.js
formatRegisterCommand function
✓ does not throw error.
return command
whose username property should be
✓ equal to username value of argument.
✓ equal to email value of argument when username value is falsy value.
whose email property should be
✓ equal to email value of argument.
whose phone property should be
✓ the value of phone property of argument that changed the first 0 to ..
whose agreement property should be
✓ return false when any of the arguments are false.
For example,
37. PASS src/business/formatRegisterCommand.test.js
formatRegisterCommand function
✓ does not throw error.
return command
whose username property should be
✓ equal to username value of argument.
✓ equal to email value of argument when username value is falsy value.
whose email property should be
✓ equal to email value of argument.
whose phone property should be
✓ the value of phone property of argument that changed the first 0 to ..
whose agreement property should be
✓ return false when any of the arguments are false.
For example,
2 Type of return value.
- command object
- false
2 Responsibilities.
- Decide whether user can join
- Format input values to command object
39. I realize how bad design skills I have.
So I'm interested in stable code and good design.
Motivation for learning
Things I really felt while doing TEST & TDD.
40. Bug tracking time is significantly reduced.
Improve development productivity
* Time saved without testing ≤ Time to fix a bug from not tested code
* It’s my subjective feeling. No objectivity.
Things I really felt while doing TEST & TDD.
41. I've found some loopholes in business logic *in advance.
Improve project productivity
*Before I (or we) start coding
Things I really felt while doing TDD.
42. TDD controls that I don’t do more than one thing at a time.
It makes me focus more on what I have to do right now.
Concentration is improved
Things I really felt while doing TDD.
43. Original article: https://www.facebook.com/notes/kent-beck/rip-tdd/750840194948847/
RIP TDD: The article criticizes DHH's article, "TDD is dead."
In this article, Kent Beck mentions the benefits of TDD.
-
Over-engineering.
I have a tendency to "throw in" functionality I "know" I'm
"going to need". Making one red test green (along with the
list of future tests) helps me implement just enough. I need
to find a new way to stay focused.