Basics of TDD. Including why? Why it is discipline. Typical Pitfalls. Kinds of TDD, and a Recipe so anyone can do testing quickly. And lots of examples.
How difficult is to automatically test the HelloWorld.
We fix it and other many difficult scenarios with techniques like:
- lower "s" singleton
- law of demeter
- dependency injection
- and more examples
This document discusses PyMongo, a Python driver for MongoDB. It provides an overview of common PyMongo operations like connecting to a database, inserting and querying documents, and using GridFS for storing and retrieving files. It also covers newer PyMongo features like commands, stored JavaScript, and awareness of datetime limits. The document encourages involvement in the PyMongo open source project.
The document discusses testing techniques and principles for writing tests. It advocates for tests that are FAST, ISOLATING, REPEATABLE, SELF-VALIDATING, and TIMELY (FIRST). It also discusses the Arrange-Act-Assert (AAA) structure for tests and how to achieve high code coverage while maintaining test quality. The document notes that while code coverage is a useful metric, it does not guarantee correctness on its own. It also covers the use of test doubles like stubs, spies, mocks and fakes to replace dependencies.
Introduction to web programming for java and c# programmers by @drpicoxDavid Rodenas
(better presented by @drpicox)
Slides of an introductory course for web programming focusing in basic Javascript and CSS concepts. It assumes knowledge of programming, Java or C#.
This is the support of a course to teach React programming for Java and C# programmers. It covers from its origins in Facebook til separation of presentational and container components. What is JSX, rules, state, props, refactoring, conditionals, repeats, forms, synchronizing values, composition, and so on.
This document provides instructions for a test-driven development (TDD) coding assignment using JavaScript. It outlines how to set up the development environment, run tests, and iterate through solving tests one by one while committing changes. It also includes an introduction to JavaScript basics like types, functions, classes, and interfaces to provide context for completing the assignment. Students are instructed to work individually on solving commented tests in a GitHub classroom repository by running tests and committing after each solved test.
This document summarizes lessons learned from building MongoDB and MongoEngine. Some key lessons include: dive in and start contributing to open source projects to help them progress; metclasses are an important tool that allow ORM functionality to be added to classes; not all new ideas are good and it's important to avoid straying too far from existing patterns that users expect; tracking changes at a granular level allows partial updates but adds complexity. Overall it encourages contributors to learn why certain approaches were taken and focus on improving existing designs rather than introducing radical changes.
A simple talk about appliyng patterns in Javascript.
It focuses in both jQuery and Angular.
It explains some basics MVC, cohesion and coupling.
It also have many examples of the patterns applied.
Full examples and documentation can be found here: http://david-rodenas.com/tutorial-jspatterns-v1/
This is the support of a course to teach mainly Redux, and Redux with React for Java and C# programmers. It is the third part of the course to recycle programmers from desktop app programming to web app programming. This course covers from history of Redux, its origin, step by step what is a reducer, and later concepts like reducer splitting, action handling, async and many more.
You also can use repositories:
- https://github.com/drpicox/learn-redux-bytesting
- https://github.com/drpicox/learn-redux-zoo-bytesting
To improve your skills.
Testing, Learning and Professionalism — 20171214David Rodenas
Two hours talk about testing, its history, its meaning and propose, a small guide of good practices, and what it is supposed to be a good professional and what is expected from us the professionals.
Here are some suggestions to improve the test method name:
- shouldReturnNullWhenQueryReturnsNull
- shouldPassNullFromDaoWhenQueryReturnsNull
Using "should" makes the intent clearer - we expect the method to return null under certain conditions. Describing those conditions ("when query returns null") in the name provides more context than a generic "testQuery".
Overall, test method names should clearly communicate what is being tested and under what conditions we expect the test to pass or fail. This helps readers understand the purpose and focus of each test.
1. The document discusses good and bad practices for writing unit tests. It emphasizes that tests should verify the expected behavior, fail clearly when something goes wrong, and use mocks and isolation to focus on the code being tested.
2. Some examples of bad tests shown include tests that don't make assertions or assertions that don't provide useful information on failure. Real objects are also used instead of mocks, obscuring the test.
3. Good practices include using mocks to isolate the code being tested, making sure tests fail clearly when something goes wrong, and focusing tests on expected behavior through clear assertions. Automated testing, fixing broken tests, and mastering testing tools are also emphasized.
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.
Использование GMock для обеспечения спокойной и сытой жизни разработчика. Обзор как верхушки так и некоторых подводных частей GMock. Разбор возможностей фреймворка на примерах.
The document describes 5 Java programming experiments related to database access and web applications:
1. A program that accesses a table from an MS Access database.
2. A similar program that accesses a table from a Derby database.
3. A program that implements remote method invocation using an interface.
4. A simple servlet program that outputs HTML.
5. A servlet program that connects to a Derby database and outputs records.
Nothing is as frustrated as deploying a new release of your web application to find out functionality you had doesn't work anymore. Of course you have all your unit tests in place and you run them through your CI environment, but nothing prepared you to a failing javascript error or a link that doesn't work anymore. Welcome to User Acceptance testing or UAT. Before you start putting real people in front of your application, create macros and export them as PHPUnit test classes. Then run them in an automated way just like your unit tests and hook them into your CI. In this talk I will show you how easy it is to create Selenium macros that can be converted into PHPUnit scripts and run automatically on different virtual machines (VM's) so you can test all different browsers on a diversity of operating systems.
Everyone talks about raising the bar on quality of code, but it's always hard to start implementing it when you have no clue where to start. With this talk I'm shooing that there are many levels developers can improve themselves by using the right tools. In this talk I'll go over each tool with examples how to use them against your codebase. A must attend talk for every developer that wants to scale up their quality. Most PHP developers deploy code that does what the customer requested but they don't have a clue about the quality of the product they deliver. Without this knowledge, maintenance can be a hell and very expensive. In this workshop I cover unit testing, code measuring, performance testing, debugging and profiling and give tips and tricks how to continue after this workshop.
The document discusses code quality analysis tools in Visual Studio 2012, including code analysis, code metrics, code clone analysis, code coverage, and unit testing. It provides examples of code issues found by code analysis tools and how to resolve them, such as fixing spelling errors, removing exceptions, using parameterized queries to prevent SQL injection, and improving code structure and maintainability.
This document summarizes key points about developer testing based on a presentation given by Vaidas Pilkauskas. It discusses 15 things to know about testing, including test phases (setup, exercise, verify, teardown), testing behavior not methods, using matchers for assertions, custom matchers, ignoring tests, exceptions, asynchronous code, controlling time in tests, collections, access modifiers, random values, number of assertions, test doubles, naming conventions, and comments. The overall message is that tests should have clear intentions, follow best practices like the single responsibility principle, and focus on testing public behavior rather than implementation details.
The document describes a network programming report on a Java chat application. It includes the code for a Server class that implements a threaded server to handle multiple client connections simultaneously. The server opens a port to listen for clients and spins up a new thread for each accepted connection. It then reads and writes data between the server and client over buffered input/output streams. The report notes issues with messages from one client not being visible to others and connection errors that can occur between the client and server.
The document contains 12 code snippets with multiple choice questions about Java concepts like threads, collections, serialization, patterns, and more. For each code snippet, 4 possible outputs are provided to choose from as the answer. The correct answers are also provided with brief explanations.
The document discusses debugging techniques and tools. It provides an overview of the debugging process, which includes understanding requirements, reproducing bugs, simplifying test cases, using the right tools, and consulting others. It also discusses debugger internals, how to control the debugger through settings like breakpoints and tracepoints, and visualization tools that can help with debugging like OzCode. The future of debugging may include more production debugging and advanced analysis capabilities.
Brief introduction to testing talk prepared to creates a starting point at TAPTAP Networks & SONATA Usa Corp. The companies where I work as Q&A Team member.
Unit testing without Robolectric, Droidcon Berlin 2016Danny Preussler
Are you bound to flaky, slow Robolectric Tests? Do you want to know a way out of it? This session shows ideas and concepts to replace Robolectric from your test code base
This document provides an overview of testing, accessing relational data, and building web applications in Clojure. It discusses using the test-is and test namespaces for testing, clojure.contrib.sql for database access using JDBC, and Compojure for building web apps with routing and HTML generation. Examples are given for writing tests, performing CRUD operations on a database, and building a web app frontend to view and create snippets.
PVS-Studio analyzer is continuously improving, and the C#-code analysis module is developing most actively: ninety new diagnostic rules were added in 2016. However, the best way to estimate the analyzer's efficiency is to look at the bugs it can catch. It's always interesting, as well as useful, to do recurring checks of large open-source projects at certain intervals and compare their results. Today I will talk about the results of the second analysis of SharpDevelop project.
The presentation is devoted to the test framework GEB for testing WEB applications and Mobile. The report will be useful for those who want to know how fast to write tests in the programming language Groovy, and not think about framework, PageObject and initializing the WebDriver. Framework is difficult - no!
This presentation by Yaroslav Sviatkin (Senior Test Automation Engineer, Consultant, GlobalLogic, Kharkiv) was delivered at QA Fest 2017 (Kyiv) on September 22, 2017.
A simple talk about appliyng patterns in Javascript.
It focuses in both jQuery and Angular.
It explains some basics MVC, cohesion and coupling.
It also have many examples of the patterns applied.
Full examples and documentation can be found here: http://david-rodenas.com/tutorial-jspatterns-v1/
This is the support of a course to teach mainly Redux, and Redux with React for Java and C# programmers. It is the third part of the course to recycle programmers from desktop app programming to web app programming. This course covers from history of Redux, its origin, step by step what is a reducer, and later concepts like reducer splitting, action handling, async and many more.
You also can use repositories:
- https://github.com/drpicox/learn-redux-bytesting
- https://github.com/drpicox/learn-redux-zoo-bytesting
To improve your skills.
Testing, Learning and Professionalism — 20171214David Rodenas
Two hours talk about testing, its history, its meaning and propose, a small guide of good practices, and what it is supposed to be a good professional and what is expected from us the professionals.
Here are some suggestions to improve the test method name:
- shouldReturnNullWhenQueryReturnsNull
- shouldPassNullFromDaoWhenQueryReturnsNull
Using "should" makes the intent clearer - we expect the method to return null under certain conditions. Describing those conditions ("when query returns null") in the name provides more context than a generic "testQuery".
Overall, test method names should clearly communicate what is being tested and under what conditions we expect the test to pass or fail. This helps readers understand the purpose and focus of each test.
1. The document discusses good and bad practices for writing unit tests. It emphasizes that tests should verify the expected behavior, fail clearly when something goes wrong, and use mocks and isolation to focus on the code being tested.
2. Some examples of bad tests shown include tests that don't make assertions or assertions that don't provide useful information on failure. Real objects are also used instead of mocks, obscuring the test.
3. Good practices include using mocks to isolate the code being tested, making sure tests fail clearly when something goes wrong, and focusing tests on expected behavior through clear assertions. Automated testing, fixing broken tests, and mastering testing tools are also emphasized.
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.
Использование GMock для обеспечения спокойной и сытой жизни разработчика. Обзор как верхушки так и некоторых подводных частей GMock. Разбор возможностей фреймворка на примерах.
The document describes 5 Java programming experiments related to database access and web applications:
1. A program that accesses a table from an MS Access database.
2. A similar program that accesses a table from a Derby database.
3. A program that implements remote method invocation using an interface.
4. A simple servlet program that outputs HTML.
5. A servlet program that connects to a Derby database and outputs records.
Nothing is as frustrated as deploying a new release of your web application to find out functionality you had doesn't work anymore. Of course you have all your unit tests in place and you run them through your CI environment, but nothing prepared you to a failing javascript error or a link that doesn't work anymore. Welcome to User Acceptance testing or UAT. Before you start putting real people in front of your application, create macros and export them as PHPUnit test classes. Then run them in an automated way just like your unit tests and hook them into your CI. In this talk I will show you how easy it is to create Selenium macros that can be converted into PHPUnit scripts and run automatically on different virtual machines (VM's) so you can test all different browsers on a diversity of operating systems.
Everyone talks about raising the bar on quality of code, but it's always hard to start implementing it when you have no clue where to start. With this talk I'm shooing that there are many levels developers can improve themselves by using the right tools. In this talk I'll go over each tool with examples how to use them against your codebase. A must attend talk for every developer that wants to scale up their quality. Most PHP developers deploy code that does what the customer requested but they don't have a clue about the quality of the product they deliver. Without this knowledge, maintenance can be a hell and very expensive. In this workshop I cover unit testing, code measuring, performance testing, debugging and profiling and give tips and tricks how to continue after this workshop.
The document discusses code quality analysis tools in Visual Studio 2012, including code analysis, code metrics, code clone analysis, code coverage, and unit testing. It provides examples of code issues found by code analysis tools and how to resolve them, such as fixing spelling errors, removing exceptions, using parameterized queries to prevent SQL injection, and improving code structure and maintainability.
This document summarizes key points about developer testing based on a presentation given by Vaidas Pilkauskas. It discusses 15 things to know about testing, including test phases (setup, exercise, verify, teardown), testing behavior not methods, using matchers for assertions, custom matchers, ignoring tests, exceptions, asynchronous code, controlling time in tests, collections, access modifiers, random values, number of assertions, test doubles, naming conventions, and comments. The overall message is that tests should have clear intentions, follow best practices like the single responsibility principle, and focus on testing public behavior rather than implementation details.
The document describes a network programming report on a Java chat application. It includes the code for a Server class that implements a threaded server to handle multiple client connections simultaneously. The server opens a port to listen for clients and spins up a new thread for each accepted connection. It then reads and writes data between the server and client over buffered input/output streams. The report notes issues with messages from one client not being visible to others and connection errors that can occur between the client and server.
The document contains 12 code snippets with multiple choice questions about Java concepts like threads, collections, serialization, patterns, and more. For each code snippet, 4 possible outputs are provided to choose from as the answer. The correct answers are also provided with brief explanations.
The document discusses debugging techniques and tools. It provides an overview of the debugging process, which includes understanding requirements, reproducing bugs, simplifying test cases, using the right tools, and consulting others. It also discusses debugger internals, how to control the debugger through settings like breakpoints and tracepoints, and visualization tools that can help with debugging like OzCode. The future of debugging may include more production debugging and advanced analysis capabilities.
Brief introduction to testing talk prepared to creates a starting point at TAPTAP Networks & SONATA Usa Corp. The companies where I work as Q&A Team member.
Unit testing without Robolectric, Droidcon Berlin 2016Danny Preussler
Are you bound to flaky, slow Robolectric Tests? Do you want to know a way out of it? This session shows ideas and concepts to replace Robolectric from your test code base
This document provides an overview of testing, accessing relational data, and building web applications in Clojure. It discusses using the test-is and test namespaces for testing, clojure.contrib.sql for database access using JDBC, and Compojure for building web apps with routing and HTML generation. Examples are given for writing tests, performing CRUD operations on a database, and building a web app frontend to view and create snippets.
PVS-Studio analyzer is continuously improving, and the C#-code analysis module is developing most actively: ninety new diagnostic rules were added in 2016. However, the best way to estimate the analyzer's efficiency is to look at the bugs it can catch. It's always interesting, as well as useful, to do recurring checks of large open-source projects at certain intervals and compare their results. Today I will talk about the results of the second analysis of SharpDevelop project.
The presentation is devoted to the test framework GEB for testing WEB applications and Mobile. The report will be useful for those who want to know how fast to write tests in the programming language Groovy, and not think about framework, PageObject and initializing the WebDriver. Framework is difficult - no!
This presentation by Yaroslav Sviatkin (Senior Test Automation Engineer, Consultant, GlobalLogic, Kharkiv) was delivered at QA Fest 2017 (Kyiv) on September 22, 2017.
The Ring programming language version 1.5.2 book - Part 7 of 181Mahmoud Samir Fayed
The document summarizes updates and new features in Ring version 1.5, including:
1) A calculator application added to the Applications folder. Better Ring Notepad updated with new styles and a main file toolbar.
2) The Ring Notepad output window displays new lines correctly and contains a clear button. It also opens and switches between large files while preparing function/class lists.
3) New functions added to the StdLib - Print2Str(), ListAllFiles(), and SystemCmd(). The WebLib updated with an HTMLPage class to create HTML outside of web applications.
4) Better support for RingQt classes including QStringRef and Bluetooth classes. An example parses an XML response from
This document provides instructions for setting up a Django development environment, including creating a Django project and application. It discusses installing virtualenv and Django, creating a project structure with manage.py, settings.py and urls.py files, setting up a SQLite database, creating models, forms and views for a TODO application, adding templates, and enabling the admin interface. The steps allow a user to build a basic TODO list application with Django to learn its core functionality and development process.
Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/254wkpw.
Aaron Bedra focuses on describing a system as a series of models that can be used to systematically and automatically generate input data and ensure that a code is behaving as expected. Bedra discusses property based testing and how it can help one build more resilient systems and even reduce the time needed to maintain a test suite. Filmed at qconlondon.com.
Aaron Bedra is Chief Security Officer at eligible.com. He is the creator of Repsheet, an open source threat intelligence framework. Bedra is the co-author of Programming Clojure, 2nd Edition and a frequent contributor to open source software.
Sample JavaScript Code Laurence Svekis
JavaScript Closure
A closure in JavaScript is a function that has access to the variables in its parent scope, even after the parent function has completed execution. This allows for data to be “closed over” or remembered by the inner function, even after the outer function has returned.
Here, the makeCounter function returns an inner function that has access to the count variable declared in its parent scope, and can “remember” the current count value even after the makeCounter function has completed execution. Each time the inner function is called, it returns the current value of count and increments it by 1.
JavaScript Closure Advanced
In this example, the makeAdder function takes in a single argument x and returns an inner function that takes in a second argument y. The inner function has access to the x variable declared in the parent scope and uses it to add x and y together and return the result.
We can see here that the outer function makeAdder has been executed twice and it returns two different inner functions which are assigned to different variables add5 and add10 and these inner functions are able to remember their respective parent scope values of x.
Building l10n Payroll Structures from the Ground upOdoo
The Payroll flow of 13.0 has been functionally and technically improved with new features. The document describes the new payroll structure types and rules that define compensation calculations. Salary rules can include Python code for evaluation that has access to contextual objects like categories, rules, payslips, worked days, and inputs to retrieve necessary values and perform calculations in the payroll process.
Python Code Camp (Professionals) is a whole day workshop that aims to enable professionals to learn Python Basics and Django.
Visit: http://devcon.ph/events/python-code-camp-professionals-2016
http://www.opitz-consulting.com/go/3-6-11
Groovy erfreut sich immer größerer Beliebtheit. Viele "grüne Wiese Projekte" werden damit und vor allem mit dem darauf aufsetzenden Grails Framework realisiert. Will man Groovy in einem bereits existierenden Java-Projekt verwenden bedeutet das nicht automatisch, dass das Projekt dazu grundlegend umgestellt werden muss. Insbesondere im Bereich der funktionalen Tests kann Groovy relativ problemlos integriert werden.
Unser Solution Architect Torsten Mandry stellte bei den SD Days am 09.11.2014 in Essen, der jährlichen Konferenz unserer Software-Development-Spezialisten, am Beispiel einer existierenden JSF-Anwendung vor, wie diese mit Hilfe von Groovy und den Frameworks Spock und Geb automatisiert getestet werden kann.
--
Über uns:
Als führender Projektspezialist für ganzheitliche IT-Lösungen tragen wir zur Wertsteigerung der Organisationen unserer Kunden bei und bringen IT und Business in Einklang. Mit OPITZ CONSULTING als zuverlässigem Partner können sich unsere Kunden auf ihr Kerngeschäft konzentrieren und ihre Wettbewerbsvorteile nachhaltig absichern und ausbauen.
Über unsere IT-Beratung: http://www.opitz-consulting.com/go/3-8-10
Unser Leistungsangebot: http://www.opitz-consulting.com/go/3-8-874
Karriere bei OPITZ CONSULTING: http://www.opitz-consulting.com/go/3-8-5
Groovy erfreut sich immer größerer Beliebtheit. Viele "grüne Wiese Projekte" werden damit und vor allem mit dem darauf aufsetzenden Grails Framework realisiert. Will man Groovy in einem bereits existierenden Java-Projekt verwenden bedeutet das nicht automatisch, dass das Projekt dazu grundlegend umgestellt werden muss. Insbesondere im Bereich der funktionalen Tests kann Groovy relativ problemlos integriert werden. Der Vortrag zeigt am Beispiel einer existierenden JSF-Anwendung wie diese mit Hilfe von Groovy und den Frameworks Spock und Geb automatisiert getestet werden kann.
The document discusses best practices for writing tests and test methods. Some key points:
1. Test method names should start with "should" to indicate the expected behavior, rather than just "test". Examples given are "shouldRejectInvalidRequests()" and "shouldSaveNewUserToDatabase()".
2. Tests should focus on testing one feature or behavior at a time. The example given is splitting a test into two separate tests - one for redirection on registration success and one for user notification.
3. Tests should be readable and understandable. Examples given are using descriptive variable names like ADMIN, LOGGED, GUEST rather than "user_1", and avoiding unnecessary details like "new URL(SERVER_
The Ring programming language version 1.7 book - Part 47 of 196Mahmoud Samir Fayed
The document provides documentation for the Ring programming language. It discusses using the Bootstrap library in Ring to generate HTML pages using objects. Examples are given to create a Bootstrap page with different styled buttons, button groups, and a modal popup. It also provides an example of a CRUD (create, read, update, delete) application using MVC (model-view-controller) pattern with Ring's datalibrary. Finally, it discusses implementing a user registration and login system with password hashing and session handling.
The Ring programming language version 1.3 book - Part 83 of 88Mahmoud Samir Fayed
This document provides examples and explanations for common questions about using Ring programming language. It demonstrates how to summarize uninitialized variables, print lists containing objects, insert items into lists, print new lines and characters, create GUI applications using Qt, work with modal windows, and connect to SQLite and other databases using ODBC. Various functions, classes and concepts in Ring like Try/Catch, NULL, ISNULL(), lists, Qt classes and ODBC are explained through code examples.
Building a Pyramid: Symfony Testing StrategiesCiaranMcNulty
The last few years have seen a huge adoption of testing practices, and an explosion of different testing tools, in the PHP space. The difficulties come when we have to choose which tools to use, in what combinations, and how to apply them to existing codebases.
In this talk we will look at what tools are available, what their strengths are, how to decide which set of tools to use for new or legacy projects, and when to prioritise decoupling and testability over the convenience we get from our frameworks.
The Ring programming language version 1.3 book - Part 30 of 88Mahmoud Samir Fayed
The document discusses using the Ring programming language to develop web applications through CGI (Common Gateway Interface). It covers configuring the Apache web server to support Ring CGI files, writing a basic "Hello World" CGI program in Ring, and using the Ring Web Library to simplify CGI development. Examples are provided that demonstrate generating HTML forms and handling HTTP GET requests to retrieve submitted form data. The Web Library features templates, file uploads, and MVC patterns to help structure full-featured web applications in Ring.
Test-driven development (TDD) is a software development process where developers first write automated tests that define desired improvements or new functions. They then write code to pass those tests and refactor the new code to acceptable standards. TDD involves writing unit tests, integration tests, and acceptance tests using tools like JUnit, FitNesse, and Cucumber. Practicing TDD can provide benefits like improved code quality, reduced bugs, and increased developer productivity.
Spicy javascript: Create your first Chrome extension for web analytics QAAlban Gérôme
Adobe Launch has a monitoring hooks API that provides more details about the rules that passed or failed. That's a great excuse for writing a Chrome extension. This will benefit you even if you have no need or experience with Adobe Launch.
This document summarizes Webrat, a tool for testing web applications in Ruby. Webrat allows automating navigation, filling forms, and making assertions on pages. It supports actions like clicking links, selecting options, attaching files, and checking for elements on pages. Webrat configurations can set the parsing library and redirect limits. When used for test-driven development, Webrat helps design, develop, and build automated regression tests for web applications.
The Ring programming language version 1.8 book - Part 49 of 202Mahmoud Samir Fayed
The document provides code examples of using Bootstrap classes and components to create buttons and modal dialog boxes in HTML. It defines CSS classes for different columns, button groups, and modal elements. Buttons are created with classname, text, and other attributes. The modal dialog box contains header, body, and footer sections with close buttons and content text. Screenshots are included of the rendered output.
This presentation will demonstrate how you can use the aggregation pipeline with MongoDB similar to how you would use GROUP BY in SQL and the new stage operators coming 3.4. MongoDB’s Aggregation Framework has many operators that give you the ability to get more value out of your data, discover usage patterns within your data, or use the Aggregation Framework to power your application. Considerations regarding version, indexing, operators, and saving the output will be reviewed.
Entering in the full TDD, including:
- how TDD works and why it is required in Agile development
- why there are so many people that say that TDD does not work
- how to fix the problems in bad TDD to make it effective
- and the primary value of the sofware: make it adaptable
This document provides instructions for completing the bowling game kata exercise in both Java and JavaScript. It outlines the kata, links to the code repositories, and provides tips for setting up the development environment and executing tests in each language. The goal is to iteratively implement the kata by copying each commit exactly through test-driven development and repetition to learn how to solve problems and design solutions in the same way.
- Testing shows the presence, not the absence of bugs. Tests are driven by requirements and business rules, focusing only on relevant cases rather than testing everything.
- Tests improve quality and confidence by verifying that each scenario works as expected. Tests serve as live documentation of the system.
- While testing has been used for decades in different forms like debugging, demonstration, and evaluation, modern test-driven development and integrated testing frameworks from the 1990s helped establish testing as a mainstream practice.
Have fast, performant, and successful web pages is a great Challenge. There are many layers involved and all of them have to work together.
In this talk I presented at FIBAlumni with collaboration of COEINF and the video recording is at http://media.fib.upc.edu/fibtv/streamingmedia/view/22/1400 (in Catalan).
It shows how all parts are involved in the success of web pages from the server up to the human brain and perception.
It introduces metrics and ways to effectively calculate and measure objectively the impact of the actions taken in the optimisation and also some ways to detect ways to optimise websites.
Basic Tutorial of React for ProgrammersDavid Rodenas
This is the support of a course to teach React programming for Java and C# programmers. It covers from its origins in Facebook til separation of presentational and container components. What is JSX, rules, state, props, refactoring, conditionals, repeats, forms, synchronizing values, composition, and so on.
From high school to university and workDavid Rodenas
Presentation mostly in Catalan.
Aquesta presentació es va fer en el Institut Bernat el Ferrer de Molins de Rei.
El públic son els alumnes d'aquest institut i s'els mostra el camí que poden seguir després en la universitat i la responsabilitat que adquireixen després com a professionals.
La versió original conté els gifs animats, la majoria extrets de giphy.com.
By beginnings of 2016 there was very little information about how to work with Angular2 and almost no information about how to scale large applications.
There was no example of how to do modules, how to inject dependences inside services, how to use ES5 and so on.
In this presentation I explained how it worked and I have also provided an example in ES5 and Typescript how it can be done:
- https://github.com/drpicox/angular2-thedoctoris-ts
- https://github.com/drpicox/angular2-thedoctoris-es5
Talk given in the Mataro University (Technocampus) to grade students about what is a Freelance.
It explains about what implies to be a Freelance, concepts about Javascript, what are Meetups and user-groups, and basic notions about MVC.
Angular 1.X Community and API DecissionsDavid Rodenas
A talk presented to AngularCamp 2016 (both January and July editions) explaining how and encourage to participate and contribute inside AngularJS core.
It contains lots of examples and screenshots of github to make the process public, visible and friendly.
Previously I have presented MVC - Model: the great forgotten, in which I have explained what models were for.
It was very well received but because it was focused only in the model concept it leak of some important concepts about the whole MVC abstraction or how it make scale into a large AngularJS.
In the previous talk I gave some hints, but not all, and the audience asked for more.
This presentation explains the whole MVS, and adaptation of MVC leveraging in Angular capacities.
It should be presented in the Angular Camp of July 2016, but unfortunately their organizers forgot about it in the votations for talk and different set of talks were selected from the same author.
This talk has been given to some of my customers in private sessions.
MVC is a very popular model and many people claim that they follow it. But, despite of this, many people does not understand what are Models and which role are they playing.
This presentation was done in the Angular Camp of January'2015, explains with AngularJS step by step what happens when we develop Applications and how Models solve a large list of potential problems.
This presentation was very well received by the audience which had been very grateful and claimed to finally understand what models were for.
(automatic) Testing: from business to university and backDavid Rodenas
This talk cares about the fundamentals of testing, a little bit history of how the professional community developed what we currently know as testing, but also about why I should care about testing? why is it important to do a test? What is important to test? What is not important to test? How to do testing?
There some examples in plnker just to see each step, and many surprises.
This talk also compares what people learned in the Computer Sciences and Engineering degrees and what people does in testing. It gives some tips to catch up with current state of art and gives some points to start changing syllabus to make better engineers.
This talk is good for beginners, teachers, bosses, but also for seasoned techies that just want to light up some of the ideas that they might have been hatching.
Spoiler alert: testing will save you development time and make you a good professional.
There are lots of talks about testing: they talk about syntax, methodologies, tools. But there is usually a missing point: Why it is important to do a test? What is important to test? What is not important to test? How to do testing?
There lots of examples in plnker just to see each step, and many surprises.
This talk is good for beginners, but also for some seasoned people that just want to light up some of the ideas that they might have been hatching.
Spoiler alert: testing will save you development time.
Concept of Problem Solving, Introduction to Algorithms, Characteristics of Algorithms, Introduction to Data Structure, Data Structure Classification (Linear and Non-linear, Static and Dynamic, Persistent and Ephemeral data structures), Time complexity and Space complexity, Asymptotic Notation - The Big-O, Omega and Theta notation, Algorithmic upper bounds, lower bounds, Best, Worst and Average case analysis of an Algorithm, Abstract Data Types (ADT)
ELectronics Boards & Product Testing_Shiju.pdfShiju Jacob
This presentation provides a high level insight about DFT analysis and test coverage calculation, finalizing test strategy, and types of tests at different levels of the product.
Raish Khanji GTU 8th sem Internship Report.pdfRaishKhanji
This report details the practical experiences gained during an internship at Indo German Tool
Room, Ahmedabad. The internship provided hands-on training in various manufacturing technologies, encompassing both conventional and advanced techniques. Significant emphasis was placed on machining processes, including operation and fundamental
understanding of lathe and milling machines. Furthermore, the internship incorporated
modern welding technology, notably through the application of an Augmented Reality (AR)
simulator, offering a safe and effective environment for skill development. Exposure to
industrial automation was achieved through practical exercises in Programmable Logic Controllers (PLCs) using Siemens TIA software and direct operation of industrial robots
utilizing teach pendants. The principles and practical aspects of Computer Numerical Control
(CNC) technology were also explored. Complementing these manufacturing processes, the
internship included extensive application of SolidWorks software for design and modeling tasks. This comprehensive practical training has provided a foundational understanding of
key aspects of modern manufacturing and design, enhancing the technical proficiency and readiness for future engineering endeavors.
Fluid mechanics is the branch of physics concerned with the mechanics of fluids (liquids, gases, and plasmas) and the forces on them. Originally applied to water (hydromechanics), it found applications in a wide range of disciplines, including mechanical, aerospace, civil, chemical, and biomedical engineering, as well as geophysics, oceanography, meteorology, astrophysics, and biology.
It can be divided into fluid statics, the study of various fluids at rest, and fluid dynamics.
Fluid statics, also known as hydrostatics, is the study of fluids at rest, specifically when there's no relative motion between fluid particles. It focuses on the conditions under which fluids are in stable equilibrium and doesn't involve fluid motion.
Fluid kinematics is the branch of fluid mechanics that focuses on describing and analyzing the motion of fluids, such as liquids and gases, without considering the forces that cause the motion. It deals with the geometrical and temporal aspects of fluid flow, including velocity and acceleration. Fluid dynamics, on the other hand, considers the forces acting on the fluid.
Fluid dynamics is the study of the effect of forces on fluid motion. It is a branch of continuum mechanics, a subject which models matter without using the information that it is made out of atoms; that is, it models matter from a macroscopic viewpoint rather than from microscopic.
Fluid mechanics, especially fluid dynamics, is an active field of research, typically mathematically complex. Many problems are partly or wholly unsolved and are best addressed by numerical methods, typically using computers. A modern discipline, called computational fluid dynamics (CFD), is devoted to this approach. Particle image velocimetry, an experimental method for visualizing and analyzing fluid flow, also takes advantage of the highly visual nature of fluid flow.
Fundamentally, every fluid mechanical system is assumed to obey the basic laws :
Conservation of mass
Conservation of energy
Conservation of momentum
The continuum assumption
For example, the assumption that mass is conserved means that for any fixed control volume (for example, a spherical volume)—enclosed by a control surface—the rate of change of the mass contained in that volume is equal to the rate at which mass is passing through the surface from outside to inside, minus the rate at which mass is passing from inside to outside. This can be expressed as an equation in integral form over the control volume.
The continuum assumption is an idealization of continuum mechanics under which fluids can be treated as continuous, even though, on a microscopic scale, they are composed of molecules. Under the continuum assumption, macroscopic (observed/measurable) properties such as density, pressure, temperature, and bulk velocity are taken to be well-defined at "infinitesimal" volume elements—small in comparison to the characteristic length scale of the system, but large in comparison to molecular length scale
Analysis of reinforced concrete deep beam is based on simplified approximate method due to the complexity of the exact analysis. The complexity is due to a number of parameters affecting its response. To evaluate some of this parameters, finite element study of the structural behavior of the reinforced self-compacting concrete deep beam was carried out using Abaqus finite element modeling tool. The model was validated against experimental data from the literature. The parametric effects of varied concrete compressive strength, vertical web reinforcement ratio and horizontal web reinforcement ratio on the beam were tested on eight (8) different specimens under four points loads. The results of the validation work showed good agreement with the experimental studies. The parametric study revealed that the concrete compressive strength most significantly influenced the specimens’ response with the average of 41.1% and 49 % increment in the diagonal cracking and ultimate load respectively due to doubling of concrete compressive strength. Although the increase in horizontal web reinforcement ratio from 0.31 % to 0.63 % lead to average of 6.24 % increment on the diagonal cracking load, it does not influence the ultimate strength and the load-deflection response of the beams. Similar variation in vertical web reinforcement ratio leads to an average of 2.4 % and 15 % increment in cracking and ultimate load respectively with no appreciable effect on the load-deflection response.
π0.5: a Vision-Language-Action Model with Open-World GeneralizationNABLAS株式会社
今回の資料「Transfusion / π0 / π0.5」は、画像・言語・アクションを統合するロボット基盤モデルについて紹介しています。
拡散×自己回帰を融合したTransformerをベースに、π0.5ではオープンワールドでの推論・計画も可能に。
This presentation introduces robot foundation models that integrate vision, language, and action.
Built on a Transformer combining diffusion and autoregression, π0.5 enables reasoning and planning in open-world settings.
Passenger car unit (PCU) of a vehicle type depends on vehicular characteristics, stream characteristics, roadway characteristics, environmental factors, climate conditions and control conditions. Keeping in view various factors affecting PCU, a model was developed taking a volume to capacity ratio and percentage share of particular vehicle type as independent parameters. A microscopic traffic simulation model VISSIM has been used in present study for generating traffic flow data which some time very difficult to obtain from field survey. A comparison study was carried out with the purpose of verifying when the adaptive neuro-fuzzy inference system (ANFIS), artificial neural network (ANN) and multiple linear regression (MLR) models are appropriate for prediction of PCUs of different vehicle types. From the results observed that ANFIS model estimates were closer to the corresponding simulated PCU values compared to MLR and ANN models. It is concluded that the ANFIS model showed greater potential in predicting PCUs from v/c ratio and proportional share for all type of vehicles whereas MLR and ANN models did not perform well.
The role of the lexical analyzer
Specification of tokens
Finite state machines
From a regular expressions to an NFA
Convert NFA to DFA
Transforming grammars and regular expressions
Transforming automata to grammars
Language for specifying lexical analyzers
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...Infopitaara
A Boiler Feed Pump (BFP) is a critical component in thermal power plants. It supplies high-pressure water (feedwater) to the boiler, ensuring continuous steam generation.
⚙️ How a Boiler Feed Pump Works
Water Collection:
Feedwater is collected from the deaerator or feedwater tank.
Pressurization:
The pump increases water pressure using multiple impellers/stages in centrifugal types.
Discharge to Boiler:
Pressurized water is then supplied to the boiler drum or economizer section, depending on design.
🌀 Types of Boiler Feed Pumps
Centrifugal Pumps (most common):
Multistage for higher pressure.
Used in large thermal power stations.
Positive Displacement Pumps (less common):
For smaller or specific applications.
Precise flow control but less efficient for large volumes.
🛠️ Key Operations and Controls
Recirculation Line: Protects the pump from overheating at low flow.
Throttle Valve: Regulates flow based on boiler demand.
Control System: Often automated via DCS/PLC for variable load conditions.
Sealing & Cooling Systems: Prevent leakage and maintain pump health.
⚠️ Common BFP Issues
Cavitation due to low NPSH (Net Positive Suction Head).
Seal or bearing failure.
Overheating from improper flow or recirculation.
2. Accounting
• Accounting is a discipline that is in charge of studying,
measuring and analyzing the assets and financial and
economic situation of a company or organization, in order
to facilitate decision-making within it and external control,
presenting the information , previously registered, in a
systematic and useful way for the different interested
parties.
—Wikipedia
2
3. Double-entry bookkeping
• At least two accounting entries are required to record
each financial transaction: debit and credit.
3
5. Test Development Driven
• The Three rules of TDD:
1. You are not allowed to write any production code unless it is
to make a failing unit test pass.
2. You are not allowed to write any more of a unit test than is
sufficient to fail; and compilation failures are failures.
3. You are not allowed to write any more production code than
is sufficient to pass the one failing unit test.
5
http://www.butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd
6. Stages of TDD
6
RED
GREEN
REFACTOR
TEST CODE
CLEAN
Write production code
until tests pass.
Write tests
until a test fails.
Clean code while tests passes.
Clean tests while tests passes.
Clean ...
...
YOU
START
HERE
30s
loop
7. Common Pitfalls (1/2)
• Typical individual mistakes include:
• forgetting to run tests frequently,
• writing too many tests at once,
• writing tests that are too large or coarse-grained,
• writing overly trivial tests, for instance omitting assertions,
• writing tests for trivial code, for instance accessors.
7
8. Common Pitfalls (2/2)
• Typical team mistakes include:
• partial adoption: only a few developers on the team use TDD,
• poor maintenance of the test suite: most commonly leading to a
test suite with a prohibitively long running time,
• abandoned test suite (i.e. seldom or never run): sometimes as a
result of poor maintenance, sometimes as a result of team
turnover.
8
9. London vs Chicago TDD
• London School of TDD: Mockists
• use spies to verify implementation
• higher coupling
• Chicago School of TDD: Statists
• depend on results, not on imlpementation details
• our objective
9
10. London Example
import { add } from "math"
import multiply from "./multiply"
let log
function addMock(a, b) {
log.push(`${a}+${b}`)
return add(a, b)
}
test("multiplies two numbers", () => {
log = []
const result = multiply(3, 4, { add: addMock })
expect(log).toEqual("0+3", "3+3", "6+3", "9+3")
expect(result).toEqual(12)
})
10
11. Chicago Example
import multiply from "./multiply"
test("multiplies two numbers", () => {
const result = multiply(3, 4)
expect(result).toEqual(12)
})
11
12. Craftsman Recipe
• You already know how to create tests and do TDD
• Probably you already do some kind of TDD manually
• You just need to write it first
• There are 5 steps to help you
12
13. Step 1: First tests
• Write first the test that gives you the excuse for writing
the first code.
13
test("create a game", () => {
const game = new Game()
})
class Game {}
14. Step 2: Progressing
• You already test manually things before and after code
• Write the test code that test that for you
14
15. Step 2: Progressing
// 1: I want to check that I can add the search box
test("There is a search box", () => {
const searchBox = getByPlaceholderText(
container,
"search"
)
expect(searchBox).toBeInTheDocument()
})
15
16. Step 2: Progressing
// 2: I want to check that I can write in the text box
test("The search box accepts text", () => {
const searchBox = getByPlaceholderText(
container,
"search"
)
userEvent.type(searchBox, "apollo x")
expect(searchBox).toHaveAttribute("value", "apollo x")
})
16
17. Step 2: Progressing
// 3: I want to check that I have a search button
test('There is a search button', () => {
const searchButton = getByText(container, 'search')
expect(searchButton).toBeInTheDocument()
})
17
18. Step 2: Progressing
// 4: I want to know that clicking in search triggers fetch
test("The search button makes a fetch from the service",
async () => {
const searchBox = getByPlaceholderText(
container,
"search"
)
userEvent.type(searchBox, "apollo x")
const searchButton = getByText(container, "search")
searchButton.click()
await fetchMock.expectGET("/api/v1/search?q=apollo%20x")
})
18
19. Step 2: Progressing
// 5: I want to know if there is the response area
test("There is a response area after doing a search", async () => {
const searchBox = getByPlaceholderText(
container,
"search"
)
userEvent.type(searchBox, "apollo x")
const searchButton = getByText(container, "search")
searchButton.click()
await fetchMock
.whenGET("/api/v1/search?q=apollo%20x")
.respond(["snoopy and charlie brown"])
const resultArea = await findByTestId(
container,
"search-response"
)
expect(resultArea).toBeInTheDocument()
})
19
20. Step 2: Progressing
// 6: I want to check that results are in the response area
test("The search result is shown in the response area", async () => {
const searchBox = getByPlaceholderText(container, "search")
userEvent.type(searchBox, "apollo x")
const searchButton = getByText(container, "search")
searchButton.click()
await fetchMock
.whenGET("/api/v1/search?q=apollo%20x")
.respond(["snoopy and charlie brown"])
const resultArea = await findByTestId(
container,
"search-response"
)
expect(resultArea).toHaveTextContent(
"snoopy and charlie brown"
)
})
20
21. Step 3: Remove UI use
• Make test express your intention, not how to use the UI
• Protect your tests from the UI changes
21
22. Step 3: Remove UI use
• Make test express your intention, not how to use the UI
• Protect your tests from the UI changes
22
23. Step 3: Remove UI use
import { search, findSearchResult } from "./__helpers__/ui.js"
test("The search result is shown in the response area",
async () => {
search(container, "apollo x")
await fetchMock
.whenGET("/api/v1/search?q=apollo%20x")
.respond(["snoopy and charlie brown"])
const resultArea = await findSearchResult(container)
expect(resultArea).toHaveTextContent(
"snoopy and charlie brown"
)
})
23
24. Step 3: Remove UI use
import { search, findSearchResult } from "./__helpers__/ui.js"
test("The search result is shown in the response area",
async () => {
search(container, "apollo x")
await fetchMock
.whenGET("/api/v1/search?q=apollo%20x")
.respond(["snoopy and charlie brown"])
const resultArea = await findSearchResult(container)
expect(resultArea).toHaveTextContent(
"snoopy and charlie brown"
)
})
24
26. Step 4: Refactor
• Make test and code easy to read and understand
26
import { search } from "./__helpers__/ui.js"
import {
theSearchServiceFor
} from "./__helpers__/searchService.js"
test("The search result is shown in the response area",
async () => {
theSearchServiceFor("apollo%20x").respond([
"snoopy and charlie brown",
])
const resultArea = search(container, "apollo x")
expect(resultArea).toHaveTextContent(
"snoopy and charlie brown"
)
})
27. Step 5: Business value
• All tests should directly express requirements
27
import { search } from "./__helpers__/ui.js"
import { theSearchServiceFor } from "./__helpers__/searchService.js"
// removed test('There is a search box', () => {
// removed test('The search box accepts text', () => {
// removed test('There is a search button', () => {
// removed test('The search button makes a fetch from the service',...
test("Search for the LEM and Module name", async () => {
theSearchServiceFor("apollo%20x").respond([
"snoopy and charlie brown",
])
const resultArea = search(container, "apollo x")
expect(resultArea).toHaveTextContent(
"snoopy and charlie brown"
)
})
28. Bonus Step: Use tables
• Refactor your test to accommodate tables
28
test.each`
text | query | response | result
${"unknown"} | ${"unknown"} | ${[]} | ${"no results"}
${"apollo"} | ${"apollo"} | ${["snoopy", "eagle"]} | ${"snoopyeagle"}
${"apollo x"} | ${"apollo%20x"} | ${["snoopy"]} | ${"snoopy"}
${"apollo x module:command"} | ${"apollo%20x&module=command"} | ${["charlie brown"]} | ${"charlie brown"}
${"module:command"} | ${"&module=command"} | ${["charlie", "columbia"]} | ${"charliecolumbia"}
`(
'Search for the LEM and module name of "$text"',
async ({ text, query, response, result }) => {
theSearchServiceFor(query).respond(response)
const resultArea = search(container, text)
expect(resultArea).toHaveTextContent(result)
}
)
30. Big Refactors
• Programmers always want to throw
away the code and start over
• They think the old code is a mess
• They are probably wrong.
30
https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/
by Joel Spolsky
It’s harder to read code than to write it.
31. Small Refactors
• Leverage on Tests: small change, test, small change, test, ...
• Clean the code and adjust the architecture, slowly and firmly
31
REFACTOR
CLEAN
32. Small Refactors
• Find a path for small changes
• Recipe for representation changes:
1. Add the structure representation → Test
2. Add a setter code → Test
3. Repeat 2. until no more setters
4. Moddify a getter code → Test
5. Repeat 4. until no more getters
6. Clean a getter code → Test & Repeat
7. Clean a setter code → Test & Repeat
8. Remove old representation → Test
32
33. Example (BGK)
export default class Game {
_score = 0;
roll(pins) {
this._score += pins;
}
score() {
return this._score;
}
}
33
34. Example (BGK)
export default class Game {
_score = 0;
_rolls = [];
roll(pins) {
this._score += pins;
}
score() {
return this._score;
}
}
34
Step 1: new representation
41. Example (Pattern)
// The square size may change
class Painter {
draw(size: number) {
drawSquare(size)
}
}
41
42. Example (Pattern)
// The painter can draw also circles with size
class Painter {
draw(shape: String, size: number) {
if (shape === "Circle") drawCircle(size)
else drawSquare(size)
}
}
42
43. Example (Pattern)
// The painter can draw also stars
class Painter {
draw(shape: String, size: number) {
if (shape === "Star") drawStar(size)
else if (shape === "Circle") drawCircle(size)
else drawSquare(size)
}
}
43
This is not right, too complex if/switch
44. Example (Pattern)
// The painter can draw also circles with size
class Painter {
draw(shape: String, size: number) {
if (shape === "circle") drawCircle(size)
else drawSquare(size)
}
}
44
45. Example (Pattern)
interface Shape {
draw(size: number);
}
class Painter {
draw(shape: String, size: number) {
if (shape === "circle") drawCircle(size)
else drawSquare(size)
}
}
45
46. Example (Pattern)
interface Shape { ... }
class Circle implements Shape {
draw(size: number) {
drawCircle(size)
}
}
class Painter {
draw(shape: String, size: number) {
if (shape === "circle") drawCircle(size)
else drawSquare(size)
}
}
46
47. Example (Pattern)
interface Shape { ... }
class Circle implements Shape {
draw(size: number) {
drawCircle(size)
}
}
class Painter {
draw(shape: String, size: number) {
if (shape === "circle") new Circle.draw(size)
else drawSquare(size)
}
}
47
48. Example (Pattern)
interface Shape { ... }
class Circle implements Shape { ... }
class Square implements Shape {
draw(size: number) {
drawSquare(size)
}
}
class Painter {
draw(shape: String, size: number) {
if (shape === "circle") new Circle.draw(size)
else drawSquare(size)
}
}
48
49. Example (Pattern)
interface Shape { ... }
class Circle implements Shape { ... }
class Square implements Shape {
draw(size: number) {
drawSquare(size)
}
}
class Painter {
draw(shape: String, size: number) {
if (shape === "circle") new Circle.draw(size)
else new Square.draw(size)
}
}
49
50. Example (Pattern)
interface Shape { ... }
class Circle implements Shape { ... }
class Square implements Shape { ... }
const shapes = {
circle: new Circle(),
square: new Square(),
};
class Painter {
draw(shape: String, size: number) {
if (shape === "circle") new Circle.draw(size)
else new Circle.draw(size)
}
}
50
51. Example (Pattern)
interface Shape { ... }
class Circle implements Shape { ... }
class Square implements Shape { ... }
const shapes = { ... };
class Painter {
draw(shape: String, size: number) {
shapes[shape].draw(size)
}
}
51
52. Example (Pattern)
interface Shape { ... }
class Circle implements Shape { ... }
class Square implements Shape { ... }
const shapes = { ... };
class Painter {
draw(shape: String = "square", size: number) {
shapes[shape].draw(size)
}
}
52
53. Example (Pattern)
interface Shape { ... }
class Circle implements Shape { ... }
class Square implements Shape { ... }
class Star implements Shape {
draw(size) {}
}
const shapes = { ... };
class Painter {
draw(shape: String = "square", size: number) {
shapes[shape].draw(size);
}
}
53
54. Example (Pattern)
interface Shape { ... }
class Circle implements Shape { ... }
class Square implements Shape { ... }
class Star implements Shape {
draw(size) {}
}
const shapes = {
circle: new Circle(),
square: new Square(),
star: new Star(),
};
class Painter {
draw(shape: String = "square", size: number) {
shapes[shape].draw(size);
}
}
54
55. Example (Pattern)
interface Shape { ... }
class Circle implements Shape { ... }
class Square implements Shape { ... }
class Star implements Shape {
draw(size) {
drawStar(size)
}
}
const shapes = { ... };
class Painter {
draw(shape: String = "square", size: number) {
shapes[shape].draw(size);
}
}
55