Speed reading exercises (promo)
Book notes:“TDD is a software development methodology in which tests are written to drive the development of an application. It was developed/rediscovered by Kent Beck in the late 1990s as part of Extreme Programming’ and was well discussed in his famous book Test-Driven Development: By Example.”
“Red-Green-Refactor is the core cycle of Test-Driven Development (TDD) methodology. The cycle involves the following steps: 1. Red: Write a failing test that describes the desired behavior of a specific feature or functionality. The test should not pass yet as the functionality has not yet been implemented. 2. Green: Write the minimum amount of production code necessary to make the failing test pass. The focus should be solely on passing the test, without worrying about code quality or design. 3. Refactor: Improve the design of the production code without changing its behavior, ensuring that all tests continue to pass. This step includes optimizing the code, removing duplication, and enhancing its overall quality.”
“When applying TDD, you need to keep in mind a simple principle from Extreme Programming: YAGNI, or You Aren’t Gonna Need It. YAGNI can be very useful for protecting developers from wasting their valuable time.”
“Domain-Specific Language (DSL) is used to write tests in natural language that can be easily understood by nontechnical people and can be interpreted by code and executed behind the scenes.”
“In his book Refactoring: Improving the Design of Existing Code, Martin Fowler listed 68 refactorings. I would recommend this book as almost a mandatory prerequisite for anyone who values clean code and high-quality code.”
“Jest is a testing framework from Facebook that allows developers to write reliable and fast-running tests in a more readable syntax. It can watch changes in test/ source files and rerun the necessary tests automatically.”
“In Jest, the describe function is used to group related tests together and create a logical structure within your test suite. It provides a way to organize and categorize tests based on a specific functionality, component, or feature.”
“The it function takes two arguments: a description string and a callback function. The description string describes what behavior or outcome you are testing. The callback function contains the actual test assertions or expectations.”
“To reduce duplication, we can utilize the beforeEach function provided by Jest to define reusable object instances. This function is automatically invoked before Jest runs each test case.”
“Jest provides an afterEach function that can be used to perform any necessary cleanup work after each test case has been run”
“toEqual and toBe may be the most common matchers you will find and use in almost every test case. As the name implies, they are used to assert whether values are equal to each other (the actual value and the expected value).”
“Jest also provides matchers for Array and Object.”
“that there is a difference between toContain and toContainEqual. Basically, toContain checks if the item is in the list by strictly comparing elements using ===. On the other hand, toContainEqual just checks the value (not the memory address).”
“we can make use of a technique called mocking where we simply simulate the function call rather than actually invoking it.”
“Jest provides a variety of ways to do this mock. The simplest one is function jest. fn for setting up a spy for a function”
“It is generally considered a best practice to keep files as small and focused as possible and to split them into separate files if they become too large.”
“A test can also be described in 3A format; the 3A (Arrange-Act-Assert) structure consists of three essential components of a test: 1. Arrange: The initial context or setup for the test 2. Act: The action or behavior being tested 3. Assert: The expected outcome or result of the test”
“It’s important to differentiate between end-to-end tests and unit tests. End-to-end tests simulate a user’s interaction with the entire application, while unit tests isolate and test individual functions or components of the application. Although end-to-end tests are great for testing the overall functionality and flow of the application, they can be slow and cumbersome to run. Unit tests, on the other hand, are faster, more focused, and can catch bugs before they make it into the codebase.”
“In React Router, the MemoryRouter is a specialized router component that allows you to manage routing within the memory of your application, rather than relying on the browser’s URL history. The MemoryRouter provides a router implementation that stores the current location and history in memory, making it useful for scenarios where you don’t need to update the browser’s URL or navigate between pages in a traditional sense.”
“The Publish-Subscribe (Pub-Sub) pattern is a messaging pattern commonly used in software architectures to facilitate communication between different components or modules. It provides a means for decoupling the sender (publisher) and receiver (subscriber) of messages, enabling them to interact without direct knowledge of each other.”
“The main principle of using Redux is the separation of concerns between the UI components and the application state.”
“In Redux, there are three principles that form its foundation: • All state is stored in a single global data source. • State is immutable or read-only. • Changes are made using pure functions.”
“The formula
view = f(state)
represents the relationship between the state and the view in a software application.”
“TypeScript is a typed superset of JavaScript that adds optional static typing and other features to the language. It allows developers to catch errors and bugs at compile time instead of runtime, making their code more robust and maintainable. TypeScript also provides advanced features like classes, interfaces, and modules that make it easier to write large-scale applications.”
fast reading practice (promo)
No comments:
Post a Comment