python |
Pythonタグが付けられた新着投稿 - Qiita |
matplotlibで2次元配列の解像度に合わせた画像を保存する方法 |
https://qiita.com/yusuke_s_yusuke/items/144381fd73986afb0207
|
matplotlib |
2023-05-22 21:15:45 |
Azure |
Azureタグが付けられた新着投稿 - Qiita |
Azure登録から始める、Azure OpenAI Serviceの使用手順 |
https://qiita.com/shmp-dev/items/be46a688d387fb484056
|
azureo |
2023-05-22 21:29:19 |
海外TECH |
MakeUseOf |
The 8 Best Apps for Your New iPhone |
https://www.makeuseof.com/tag/apps-new-iphone/
|
worth |
2023-05-22 12:15:18 |
海外TECH |
DEV Community |
Mastering React Interview: Top Common Questions and Best Practices |
https://dev.to/aradwan20/mastering-react-interview-top-common-questions-and-best-practices-3g13
|
Mastering React Interview Top Common Questions and Best Practices Introduction Importance of React interviews How to use this guide Getting to Know the Basics What is React Key features and benefits React vs other popular frameworks Components and Props Your Building Blocks Understanding components Functional vs class components Props and their usage PropTypes and type checking Managing Data and Component Lifecycles What is state Handling state in class components Handling state in functional components Common lifecycle methods React Hooks Enhancing Functional Components What are hooks useState and useEffect Custom hooks and their benefits Rules of hooks React and Redux State Management Made Easy What is Redux The role of Redux in React applications Connecting React components to Redux store Redux middleware React Router and Navigation Building Seamless User Experiences Implementing navigation in React Configuring React Router Nested routes and route parameters Redirects and protected routes Performance Optimization Techniques Understanding the React virtual DOM PureComponent and React memo Lazy loading and code splitting Profiling and identifying performance bottlenecks Testing and Best Practices Ensuring Quality Testing strategies for React applications Popular testing libraries and frameworks Mocking and snapshot testing Tips for writing maintainable and scalable React code Let Us Answer Some Questions What are the differences between the real DOM vs virtual DOM and shadow DOM What is the difference between an element and a component Can you write React without JSX How to pass a value from a parent component to a child and vice versa What is a higher order component What is the difference between prop and state What is a component lifecycle What parameter does useEffect take in and when it runs What is the difference between context API and prop drilling Conclusion Wrapping Up and Preparing for Your React Interview Preparing for the Interview Common Pitfalls and How to Avoid Them Additional Resources and Next Steps Introduction Welcome to our comprehensive guide to help you excel in React interviews In this article we ll provide you with an in depth understanding of key React concepts and best practices while keeping it simple and engaging Our aim is to help you navigate the React interview process with ease and confidence Let s dive in Importance of React interviewsReact has become one of the most popular and widely used front end libraries thanks to its flexibility performance and ease of use As a result React developers are in high demand and companies are always on the lookout for skilled professionals who can hit the ground running Acing a React interview is not just about showcasing your technical prowess but also demonstrating your problem solving skills and ability to adapt to new challenges By preparing well for these interviews you re not only increasing your chances of landing that dream job but also expanding your knowledge and becoming a better developer How to use this guideThis guide is designed to cover the most common topics you may encounter during a React interview Each section will provide you with a concise yet detailed explanation of the topic as well as real world examples and best practices To get the most out of this guide we recommend the following approach Start by reading through each section to gain a general understanding of the concepts Pay close attention to the code examples as they will help you visualize the concepts in practice Try out the code examples yourself to reinforce your understanding and gain hands on experience After completing the guide test your knowledge by attempting sample React interview questions Remember practice makes perfect Don t be afraid to explore additional resources and tutorials to deepen your understanding of React With dedication and perseverance you ll be well prepared to tackle any React interview question with confidence Now let s begin our journey towards mastering the React interview Getting to Know the BasicsIn this section we ll explore the fundamentals of React its key features and benefits and how it compares to other popular frameworks Don t worry we ll keep things simple and easy to understand with clear examples to help you grasp the concepts What is React React developed by Facebook is an open source JavaScript library for building user interfaces UI in web applications It allows developers to create reusable UI components and efficiently manage the way data is displayed and updated React has gained massive popularity among developers and companies alike for its simplicity flexibility and performance Key features and benefitsHere are some of the key features and benefits of using React Component based architecture React promotes a modular approach by breaking down complex UIs into smaller reusable components This makes the code more manageable scalable and easier to maintain Virtual DOM React uses a virtual representation of the actual DOM Document Object Model to track changes in the UI When a component s state changes React calculates the difference called diffing between the virtual DOM and the actual DOM then updates only the affected elements This process known as reconciliation improves performance by minimizing DOM manipulations Unidirectional data flow In React data flows in a single direction from parent to child components through props This makes it easier to understand and debug the flow of data within the application JSX JavaScript XML React uses JSX a syntax extension for JavaScript to describe the structure and appearance of UI components JSX combines HTML and JavaScript making it more readable and easier to write function WelcomeMessage return lt h gt Hello world lt h gt React vs other popular frameworksReact is often compared to other popular frameworks and libraries such as Angular and Vue js Let s see how React stacks up against them React vs Angular Angular developed by Google is a full fledged framework that includes built in solutions for routing state management and form validation React on the other hand is a library focused solely on the UI While Angular enforces a strict structure and follows the Model View Controller MVC pattern React offers more flexibility allowing developers to choose their preferred tools and libraries React s virtual DOM and lightweight nature often result in better performance compared to Angular React vs Vue js Vue js is a progressive framework with a gentle learning curve making it a popular choice for developers new to the world of front end development Like React Vue js also utilizes a virtual DOM and a component based architecture However Vue js provides a more flexible template syntax compared to JSX React has a larger community more resources and wider adoption in the industry while Vue js is praised for its simplicity and ease of integration In summary React s popularity flexibility and performance make it a strong choice for front end development While other frameworks have their own strengths React continues to be a dominant force in the industry By understanding the fundamentals of React you re laying a solid foundation for your journey as a React developer Components and Props Your Building BlocksIn this section we ll explore the core concepts of React components and props and how they help you create powerful and reusable UI elements We ll keep things simple with clear explanations and code examples to illustrate the concepts Understanding componentsComponents are the building blocks of any React application They represent individual UI elements such as buttons forms or lists and can be reused throughout your application Components can be combined and nested to create complex UIs while keeping the code clean and maintainable A React component can be defined as a simple JavaScript function that takes input called props and returns a React element describing what should appear on the screen function WelcomeMessage props return lt h gt Hello props name lt h gt Functional vs class componentsThere are two ways to create components in React functional components and class components Functional components These are simple JavaScript functions that take props as input and return a React element They are the most common type of components in modern React applications due to their simplicity and support for hooks function Greeting props return lt h gt Welcome props name lt h gt Class components These are ES classes that extend React Component They include a render method that returns a React element and can have additional methods and state class Greeting extends React Component render return lt h gt Welcome this props name lt h gt While class components were once the standard functional components are now preferred for their simplicity and the introduction of React hooks which enable state and lifecycle features in functional components Props and their usageProps short for properties are the way data is passed from parent components to child components in React They allow you to create dynamic and reusable components Props are read only which means child components should not modify the props they receive Here s an example of passing props to a Greeting component function App return lt Greeting name John gt In the Greeting component you can access the name prop using props name function Greeting props return lt h gt Welcome props name lt h gt PropTypes and type checkingIn a React application it s essential to ensure that components receive the correct type of props PropTypes is a built in library that allows you to define the expected prop types for a component and display warnings during development if the types don t match To use PropTypes first import the library import PropTypes from prop types Next define the expected prop types for your component Greeting propTypes name PropTypes string isRequired In this example we ve specified that the name prop should be a required string If the Greeting component receives a prop with an incorrect type a warning will be displayed in the console during development Managing Data and Component LifecyclesIn this section we ll explore the concepts of state and lifecycle methods in React and how they help you manage your application s data and component behavior We ll provide simple explanations and code examples to help you grasp these important concepts What is state State is an object that holds data relevant to a component It allows components to have dynamic behavior by storing and updating the data displayed on the screen State is private and fully controlled by the component it belongs to When a component s state changes React automatically re renders the component to update the UI Handling state in class componentsIn class components you can initialize state in the constructor and use the setState method to update the state Here s an example of a simple counter component using state in a class component class Counter extends React Component constructor props super props this state count increment this setState count this state count render return lt div gt lt h gt Count this state count lt h gt lt button onClick gt this increment gt Increment lt button gt lt div gt Handling state in functional componentsWith the introduction of React hooks managing state in functional components has become much easier The useState hook allows you to create state variables in functional components Here s the same counter component using a functional component with the useState hook import React useState from react function Counter const count setCount useState function increment setCount count return lt div gt lt h gt Count count lt h gt lt button onClick increment gt Increment lt button gt lt div gt Common lifecycle methodsLifecycle methods are special methods in class components that allow you to perform actions at different stages of a component s life such as mounting updating or unmounting Here are some common lifecycle methods componentDidMount This method is called once the component has been rendered to the DOM It s a good place to fetch data set up timers or perform other side effects componentDidMount Fetch data set up timers or perform other side effects here componentDidUpdate This method is called whenever a component s props or state change It allows you to perform side effects in response to updates such as updating the DOM or fetching new data componentDidUpdate prevProps prevState Perform side effects in response to component updates componentWillUnmount This method is called just before a component is removed from the DOM It s a good place to clean up timers cancel network requests or remove event listeners componentWillUnmount Clean up timers network requests or event listeners here With React hooks these lifecycle methods can be replaced by the useEffect hook in functional components For example the componentDidMount and componentWillUnmount behavior can be achieved like this import React useEffect from react function ExampleComponent useEffect gt Perform side effects similar to componentDidMount return gt Clean up similar to componentWillUnmount rest of the component React Hooks Enhancing Functional ComponentsIn this section we ll delve into the world of React hooks a powerful feature that has transformed the way we write functional components We ll cover the basics of hooks their benefits and the rules you need to follow when using them As always we ll provide clear explanations and code examples to help you grasp these important concepts What are hooks Hooks are a relatively new addition to React introduced in version They allow you to use state and other React features like lifecycle methods directly in functional components without having to convert them to class components Hooks make it easier to reuse stateful logic between components leading to cleaner and more maintainable code useState and useEffectTwo of the most commonly used hooks are useState and useEffect useState This hook allows you to create state variables in functional components It returns a pair the current state value and a function to update it const count setCount useState useEffect This hook allows you to perform side effects in functional components such as fetching data setting up timers or manipulating the DOM It can replace lifecycle methods like componentDidMount componentDidUpdate and componentWillUnmount useEffect gt Perform side effects here return gt Clean up when the component unmounts dependencies Custom hooks and their benefitsCustom hooks are user defined hooks that allow you to encapsulate and reuse stateful logic between components They follow the same naming convention as built in hooks starting with the word use Creating a custom hook is as simple as extracting the logic from a functional component into a separate function Here s an example of a custom hook for fetching data function useFetch url const data setData useState null const loading setLoading useState true useEffect gt fetch url then response gt response json then data gt setData data setLoading false url return data loading By using custom hooks you can Share stateful logic between components without duplicating codeSimplify complex components by separating concernsImprove code readability and maintainability Rules of hooksThere are two important rules you must follow when using hooks Only call hooks at the top level Don t call hooks inside loops conditions or nested functions This ensures that hooks are called in the same order on each render allowing React to correctly preserve the state Only call hooks from React functions Hooks should only be called from React functional components or custom hooks Avoid calling hooks from regular JavaScript functions By adhering to these rules you ll ensure that your hooks work as expected and maintain consistency in your code In conclusion React hooks are a game changer for functional components enabling you to use state and lifecycle features without the need for class components React and Redux State Management Made EasyIn this section we ll discuss the popular state management library Redux and how it can be integrated with React applications We ll cover the basics of Redux its role in React applications connecting components to the Redux store and working with Redux middleware As always we ll provide simple explanations and code examples to help you understand these concepts What is Redux Redux is an open source JavaScript library for managing the state of your application It helps you maintain a predictable state container making it easier to test and debug your applications Redux is often used with React but can be utilized with other JavaScript frameworks as well The role of Redux in React applicationsIn a React application managing state can become complex as your application grows Redux provides a centralized store for the state of your application making it easier to manage and share state across components Redux enforces a unidirectional data flow and a strict update pattern promoting consistency and predictability in your application s behavior Connecting React components to Redux storeTo connect your React components to the Redux store you ll need the react redux library The main components you ll work with are the Provider and connect function Provider Wraps your application making the Redux store available to all components import Provider from react redux import store from store ReactDOM render lt Provider store store gt lt App gt lt Provider gt document getElementById root connect A higher order function that connects a React component to the Redux store allowing it to access the store s state and dispatch actions import connect from react redux function mapStateToProps state return counter state counter function mapDispatchToProps dispatch return increment gt dispatch type INCREMENT export default connect mapStateToProps mapDispatchToProps CounterComponent Redux middlewareMiddleware in Redux is a way to extend the behavior of the store by adding custom logic in the middle of the dispatch process Middleware can be used for various purposes such as logging handling asynchronous actions or enforcing specific rules To use middleware in Redux you ll need to apply it when creating the store import createStore applyMiddleware from redux import thunk from redux thunk import rootReducer from reducers const store createStore rootReducer applyMiddleware thunk In this example we re using the redux thunk middleware which allows you to write action creators that return functions instead of plain objects This is useful for handling asynchronous actions such as fetching data from an API function fetchPosts return dispatch gt dispatch requestPosts return fetch then response gt response json then json gt dispatch receivePosts json By integrating Redux with your React applications you can simplify state management improve the predictability of your application s behavior and make it easier to test and debug your code Don t forget to practice working with Redux and React to solidify your understanding and become more comfortable with this powerful combination React Router and Navigation Building Seamless User ExperiencesIn this section we ll discuss how to implement navigation in React applications using the popular library React Router We ll cover the basics of configuring React Router working with nested routes and route parameters and handling redirects and protected routes As always we ll provide simple explanations and code examples to help you understand these concepts Implementing navigation in ReactIn single page applications SPAs like those built with React traditional navigation is replaced by client side routing React Router is a popular library for managing client side navigation allowing you to create seamless user experiences while maintaining the benefits of SPAs Configuring React RouterTo get started with React Router you ll need to install it and import the necessary components npm install react router domThen import the components and configure your routes import BrowserRouter as Router Route Switch Link from react router dom function App return lt Router gt lt nav gt lt ul gt lt li gt lt Link to gt Home lt Link gt lt li gt lt li gt lt Link to about gt About lt Link gt lt li gt lt li gt lt Link to contact gt Contact lt Link gt lt li gt lt ul gt lt nav gt lt Switch gt lt Route exact path component Home gt lt Route path about component About gt lt Route path contact component Contact gt lt Switch gt lt Router gt Nested routes and route parametersReact Router supports nested routes allowing you to create more complex navigation structures You can also use route parameters to capture values from the URL and pass them to your components import Route useParams from react router dom function BlogPost const postId useParams Fetch and display the post with the given postId function Blog return lt gt lt Route exact path blog component BlogList gt lt Route path blog postId component BlogPost gt lt gt Redirects and protected routesSometimes you may want to redirect users based on certain conditions like authentication status React Router provides the Redirect component to handle this import Route Redirect from react router dom function PrivateRoute component Component isAuthenticated rest return lt Route rest render props gt isAuthenticated lt Component props gt lt Redirect to login gt gt In this example we ve created a PrivateRoute component that checks the isAuthenticated prop If the user is authenticated they can access the route otherwise they are redirected to the login page Performance Optimization TechniquesIn this section we ll discuss various techniques to optimize the performance of your React applications We ll cover topics like the React virtual DOM PureComponent and React memo lazy loading and code splitting and profiling to identify performance bottlenecks As always we ll provide simple explanations and code examples to help you understand these concepts Understanding the React virtual DOMReact uses a virtual DOM to improve the performance of your applications The virtual DOM is an in memory representation of the actual DOM which allows React to calculate the difference called the diff between the current and new DOM states This way React updates only the necessary parts of the actual DOM reducing the amount of DOM manipulation and improving the performance PureComponent and React memoPureComponent and React memo are two methods to optimize the performance of your components by preventing unnecessary re renders PureComponent PureComponent is a class component that only re renders if its props or state have changed It does a shallow comparison which can help prevent unnecessary re renders and improve performance import React PureComponent from react class MyComponent extends PureComponent render Your component implementation React memo Similar to PureComponent React memo is a higher order component for functional components that only re renders if its props have changed It also does a shallow comparison import React from react const MyComponent React memo function MyComponent props Your component implementation Lazy loading and code splittingLazy loading and code splitting are techniques to reduce the initial load time of your application by only loading the necessary parts of your application when needed Lazy loading React lazy is a function that allows you to load components lazily as they re needed It works with dynamic imports which return a Promise that resolves to a module containing a React component import React lazy Suspense from react const MyComponent lazy gt import MyComponent function App return lt div gt lt Suspense fallback lt div gt Loading lt div gt gt lt MyComponent gt lt Suspense gt lt div gt Code splitting Code splitting is the process of breaking up your application s code into smaller chunks which can be loaded on demand This can be achieved using Webpack s dynamic imports or the React lazy function mentioned above Profiling and identifying performance bottlenecksReact provides a Profiler API to measure the performance of your application allowing you to identify and address performance bottlenecks The Profiler can be added to your component tree and will measure the rendering time and frequency of updates for the components within the tree import React Profiler from react function onRenderCallback id the id prop of the Profiler tree that has just committed phase either mount if the tree just mounted or update if it re rendered actualDuration time spent rendering the committed update baseDuration estimated time to render the entire subtree without memoization startTime when React began rendering this update commitTime when React committed this update interactions the Set of interactions belonging to this update Log the results function App return lt Profiler id MyComponent onRender onRenderCallback gt lt MyComponent gt lt Profiler gt Testing and Best Practices Ensuring QualityIn this section we ll discuss various testing strategies and best practices for your React applications We ll cover topics like testing strategies popular testing libraries and frameworks mocking and snapshot testing and tips for writing maintainable and scalable React code As always we ll provide simple explanations and code examples to help you understand these concepts Testing strategies for React applicationsTesting is an essential part of developing robust React applications A well thought out testing strategy can help you catch errors early and ensure that your application behaves as expected Some common testing strategies for React applications include Unit testing Testing individual components or functions in isolation Integration testing Testing the interaction between multiple components or parts of your application End to end EE testing Testing your application as a whole simulating real user interactions Popular testing libraries and frameworksThere are several popular libraries and frameworks available for testing React applications including Jest A popular testing framework that provides an extensive set of features for testing JavaScript and React applications React Testing Library A library that encourages best practices for testing React components by focusing on their behavior and what the user sees Enzyme A testing utility for React that makes it easier to test components by providing a shallow rendering API and other utilities Mocking and snapshot testingMocking and snapshot testing are two useful techniques for testing React components Mocking Mocking is the process of creating fake objects or functions to replace real dependencies in your tests This allows you to isolate the code being tested and control the behavior of external dependencies Jest provides built in support for mocking functions and modules import axios from axios import fetchData from fetchData jest mock axios test fetches data from the API async gt const data data result test data axios get mockResolvedValue data const result await fetchData expect result toEqual data data result Snapshot testing Snapshot testing compares the rendered output of a component to a stored snapshot which serves as the expected output If the output changes the test will fail ensuring that unintentional changes are caught early Jest provides built in support for snapshot testing import React from react import render from testing library react import MyComponent from MyComponent test matches the snapshot gt const container render lt MyComponent gt expect container firstChild toMatchSnapshot Tips for writing maintainable and scalable React codeTo ensure that your React applications remain maintainable and scalable as they grow follow these best practices Keep your components small and focused on a single responsibility Use functional components and hooks when possible as they tend to be more concise and easier to test Use PropTypes to validate component props and catch errors early Write reusable and modular code and avoid duplicating logic across components Keep your file and folder structure organized and group related components and files together Let Us Answer Some QuestionsIn this section we ll answer some common questions related to React providing detailed information and code examples to help you understand the concepts more easily What are the differences between the real DOM vs virtual DOM and shadow DOM Real DOM The real DOM Document Object Model is the actual representation of your web page in the browser s memory Manipulating the real DOM is slow and performance intensive Virtual DOM The virtual DOM is an in memory representation of the real DOM used by React to calculate the difference called diff between the current and new DOM states This way React updates only the necessary parts of the actual DOM reducing the amount of DOM manipulation and improving performance Shadow DOM The shadow DOM is a web standard that provides a way to create isolated encapsulated DOM trees for web components It helps to keep your components markup styles and scripts separated from the main DOM avoiding conflicts with other elements on the page What is the difference between an element and a component Element An element is an immutable object that represents a DOM node Elements are created using React s createElement function or JSX syntax Component A component is a reusable piece of UI that can accept input props and return a React element Components can be either functional stateless or class based stateful Can you write React without JSX Yes you can write React without JSX JSX is just syntactic sugar for React createElement Here s an example of a React component written without JSX import React from react function MyComponent return React createElement div null Hello World How to pass a value from a parent component to a child and vice versa To pass a value from a parent component to a child component use props To pass a value from a child component to a parent component use a callback function Here s an example import React useState from react function Parent const value setValue useState return lt div gt lt Child value value onValueChange setValue gt lt div gt function Child value onValueChange const handleChange e gt onValueChange e target value return lt input type text value value onChange handleChange gt What is a higher order component A higher order component HOC is a function that takes a component and returns a new component with additional props or behavior HOCs are a way to reuse component logic function withExtraProps WrappedComponent extraProps return function props return lt WrappedComponent props extraProps gt What is the difference between prop and state Prop Props short for properties are the input to a component They are passed from a parent component and are immutable within the component State State is the internal data managed by a component State can change over time and trigger a re render of the component What is a component lifecycle A component lifecycle refers to the sequence of events that occur during a component s life in a React application from its creation to its removal Lifecycle methods in class components or hooks in functional components allow you to run code at specific points during the component s lifecycle like mounting updating and unmounting What parameter does useEffect take in and when it runs useEffect is a hook that takes two parameters a function effect and an optional dependency array The effect function runs After the component mounts when no dependencies are provided or when the dependencies have changed After the component updates if the dependencies have changed Before the component unmounts if a cleanup function is returned by the effect function Here s an example import React useEffect useState from react function Example const count setCount useState useEffect gt document title Count count return gt document title React App count return lt div gt lt button onClick gt setCount count gt Increase Count lt button gt lt div gt What is the difference between context API and prop drilling Context API The context API is a feature in React that allows you to share global data like themes or user information with multiple components without passing props through intermediate components You create a context using React createContext then provide its value using a Provider component and consume it in child components using the useContext hook or Consumer component Prop drilling Prop drilling is a technique where you pass data through multiple levels of components in the component tree even if some intermediate components don t need the data It can lead to less maintainable and less efficient code The context API can help mitigate prop drilling by providing a way to share data without passing it through intermediate components Image by Freepik Conclusion Wrapping Up and Preparing for Your React InterviewIn this final section we will provide you with some tips on preparing for your React interview discuss common pitfalls and recommend additional resources to help you continue your learning journey Preparing for the InterviewReview the core concepts of React such as components state props hooks and the component lifecycle Practice answering common React interview questions like the ones covered in this article Build small projects or refactor existing ones to demonstrate your understanding of React best practices and patterns Familiarize yourself with related technologies such as Redux React Router and popular testing libraries Common Pitfalls and How to Avoid ThemNot understanding the fundamentals Ensure you have a strong foundation in JavaScript and React basics before diving into advanced concepts Over engineering solutions Focus on simplicity and readability Avoid complex solutions when a simpler approach is sufficient Ignoring performance considerations Be aware of the performance implications of your code and use optimization techniques such as memoization code splitting and virtual DOM when necessary Neglecting accessibility Keep accessibility in mind and follow best practices such as using semantic HTML and proper ARIA attributes Additional Resources and Next StepsReact Official Documentation The official React documentation is an excellent resource for learning and staying up to date with React Redux Documentation The official Redux documentation covers everything you need to know about using Redux with React React Router Documentation The official React Router documentation provides guidance on using React Router for navigation in your React applications Create React App A popular toolchain for creating and configuring new React projects with minimal setup |
2023-05-22 12:49:20 |
海外TECH |
DEV Community |
#TestCulture 🦅 Episode 34 – Systemic view |
https://dev.to/mathilde_llg/testculture-episode-34-systemic-view-25h3
|
TestCulture Episode Systemic viewSAFe applies this principle to understand software development as a whole because ️⃣the solution is a system in its own right️⃣the company that builds this system is a system in its own right️⃣this company must optimise the entire value stream️⃣if the global system is not managed it will not manage itself and will end up constituting autonomous but individual independent parts that will compete with each other Each part must therefore be pushed to cooperate What is the application of systemic view to test maturity Without a global approach testing is limited to a reactive position and anticipation only leads to a tunnel effect Agile with its iterative and short approach reduces this effect but leaves testers in a situation where they have very little time Leading them to test after the sprint when the Product Owner should have a potentially deliverable Product Increment ️Learn more about Systemic View hereA thread on Twitter |
2023-05-22 12:16:35 |
海外TECH |
DEV Community |
[Nestia] Make NestJS 30x faster with fastify |
https://dev.to/samchon/nestia-make-nestjs-30x-faster-with-fastify-133l
|
Nestia Make NestJS x faster with fastify Outlinenestia and fastify enhances NestJS server performance about x to x higher Previous Article Boost up NestJS server much faster and easierGithub Repository Guide Documents In previous article I introduced my library nestia making NestJS much easier and much faster In the article introducing performance enhancements I had told that nestia can boost up vaildation speed maximum x faster JSON serialization is x faster By the way some people have asked me like that Okay your nestia makes NestJS server faster by boosting up validation and serialization speeds enormously By the way how about entire server performance I especially want to know that how much nestia can increase the number of simultaneous connections How about nestia performance in the entire server level Today I came back with answer The answer is nestia fastify increases NestJS server availabitily about x to x I ll show you how I ve measured it and describe how only validation and JSON serialization can affect entire server performance Measured on Surface Pro For reference you can run the benchmark program on your computer by following below commands After the benchmark a report would be issued under nestia benchmark results YOUR CPU NAME directory If you send the result PR on my repo I d pleasure and appreciate it even more git clone cd nestia benchmarknpm installnpm start Validation How to useimport TypedBody TypedParam TypedRoute from nestia core import Controller from nestjs common import IBbsArticle from IBbsArticle Controller bbs articles export class BbsArticlesController TypedRoute Put id public async update TypedParam id uuid id string TypedBody input IBbsArticle IUpdate x faster validation Promise lt void gt When you develop a NestJS backend server with nestia you can easily validate request body data just by using nestia TypedBody decorator function like above For reference unlike class validator and class transform being used by NestJS which require triple duplicated schema definitions nestia can utilize pure TypeScript type Look at below code snippet then you may understand how nestia makes DTO schema definition easily NESTJS class validator class transform REQUIRES TRIPLE DUPLICATED DEFINITION export class BbsArticle ApiProperty type gt AttachmentFile nullable true isArray true description List of attached files Type gt AttachmentFile IsArray IsOptional IsObject each true ValidateNested each true files AttachmentFile null BESIDES NESTIA UNDERSTANDS PURE TYPESCRIPT TYPE export interface IBbsArticle files IAttachmentFile null Individual PerformanceMeasured on Intel i g Surface Pro When measuring validation performance nestia nestia utilizes typia assert lt T gt function is maximum x times faster than class validator used by NestJS by default How do you think about if such a fast validation speed is applied to entire server level As validation of request body data takes small portion of the entire backend server so is this performance difference not sufficiently impactful at the overall server level Or x times gap is an enormous value therefore would affect to the entire server performance Let s see below server benchmark graph Server PerformanceMeasured on Intel i g Surface Pro The answer was the entire server level performance be affected significantly When comparing performance in the entire server level with simultaneous connections nestia can increase the number of simultaneous connections about x higher than NestJS If adapt fastify such a performance gap would be increased up to x Besides adapting fastify in NestJS only gains performacne about I think such significant difference caused by two reasons The st is validations are processed in the main thread As you know the strength of NodeJS is events represented by non blocking I O all of which run in the background However request body data validation is processed in the main thread so if such validation logic is slow it stops entire backend server The nd reason is just x gap Even though request body data validation is a small work within framework of the entire server processes if the performance gap is x times it would be a significant difference Considering main thread operation with x performance gap above benchmark result is enough reasonable ReferenceFor reference request body validation utilzed an Array instance with length If reduce the length to be performance enhancement be halfed about Otherwise as increase the length to be larger as performance enhancement be dramatically increased IBoxD SIMILAR DTOS ARE USED WITH LENGTH ARRAYexport interface IBoxD scale IPointD position IPointD rotate IPointD pivot IPointD export interface IPointD x number y number z number JSON Serializaiton How to useimport TypedBody TypedParam from nestia core import Controller from nestjs common import typia from typia import IBbsArticle from IBbsArticle Controller bbs articles export class BbsArticlesController TypedRoute Get id x faster JSON serialization public async at TypedParam id uuid id string Promise lt IBbsArticle gt return typia random lt IBbsArticle gt When you develop a NestJS backend server with nestia you can easily boost up JSON serialization speed just by using nestia EncryptedRoute method decorator function like above For reference unlike class validator and class transform being used by NestJS which require triple duplicated schema definitions nestia can utilize pure TypeScript type Look at below code snippet then you may understand how nestia makes DTO schema definition easily NESTJS class validator class transform REQUIRES TRIPLE DUPLICATED DEFINITION export class BbsArticle ApiProperty type gt AttachmentFile nullable true isArray true description List of attached files Type gt AttachmentFile IsArray IsOptional IsObject each true ValidateNested each true files AttachmentFile null BESIDES NESTIA UNDERSTANDS PURE TYPESCRIPT TYPE export interface IBbsArticle files IAttachmentFile null Individual PerformanceDo you remember I d written an article about my another library typia and had compared JSON serialization performance between typia and class transformer In the previous benchmark typia was maximum x times faster than class transformer For reference nestia utilizes typia and NestJS utilizes class transformer Previous Article I made Express faster than FastifyGithub Repository Guide Documents Measured on Intel i g Surface Pro How do you think about if such a fast JSON serialization speed is applied to entire server level As JSON serialization performance enhancement is much smaller than validator case x vs x so is this performance difference not sufficiently impactful at the overall server level Or x times gap would affect to the entier server performance because JSON serialization is heavier work than validation Let s see below server benchmark graph Server PerformanceMeasured on Intel i g Surface Pro The answer was the entire server level performance be affected significantly too When comparing performance in the entire server level with simultaneous connections nestia can increase the number of simultaneous connections about x higher than NestJS If adapt fastify such a performance gap would be increased up to x Besides adapting fastify in NestJS only gains performacne about I think such significant difference caused by two reasons The st reason is same with validation case JSON serializations are processed in the main thread As you know the strength of NodeJS is events represented by non blocking I O all of which run in the background However request body data validation is processed in the main thread so if such validation logic is slow it stops entire backend server The nd reason is JSON serialization is heavier process than validation Therefore even though JSON serialization gains less performance than validation x vs it would be still significant at the entire server level Considering main thread operation and heavier JSON serialization process than validation above benchmark result is enough reasonable Composite Performanceimport TypedBody TypedRoute from nestia core import Controller from nestjs common import IBbsArticle from IBbsArticle Controller bbs articles export class BbsArticlesController TypedRoute Post public async store TypedBody input IBbsArticle IStore Promise lt IBbsArticle gt return input id bed e bde deefd created at T Z The last benchmark is about composite performance validating request body data and serialize JSON response data at the same time As nestia had shown significant performance gaps composite benhcmark also shows significant performance gaps Let s see below benchmark graph and imagine how much performance would be increased if you adapt nestia in your NestJS backend server I think that no more reason not to use nestia It is much faster and even much easier Measured on Intel i g Surface Pro Conclusionnestia boosts up NestJS server performance significantlyIf adapt fastify with nestia the performance would be increased moreOtherwise adapt fastify without nestia the performance would not be increasedLet s use nestia when developing NestJS backend serverMuch fasterMuch easierEven supports SDK generation like tRPCLeft is server code and right is client frontend code |
2023-05-22 12:15:18 |
海外TECH |
DEV Community |
FLaNK Stack Weekly for 22 May 2023 |
https://dev.to/tspannhw/flank-stack-weekly-for-22-may-2023-1fgc
|
FLaNK Stack Weekly for May May FLiPN FLaNK Stack WeeklyTim Spann PaaSDevIt was amazing in Raleigh Durham The people are friendly the food is great and IBM run amazing events When the Data AI and Streaming come together great things happen Next time more Pac Man look for meetups roadshows events demos examples articles videos and more coming out of this All Open Source All the Time NiFi NiFi Registry Schema Registry Presto Iceberg Hive Impala Kudu HBase Kudu Ozone MiNiFi Spark Airflow Flink Hue Yunikorn Ranger Livy Knox Atlas Phoenix Calcite Tika Solr Lucene Zeppelin Juypter CDPCLI Cybersec So many more How to do Open Source LLM with your enterprise data I am impressed what the team cooked up so fast CODE COMMUNITYPlease join my meetup group NJ NYC Philly Virtual I am working on some joint meetups and hope to bring out awesome pretzels This is Issue Videos t s pp ygUOdGltIHNwYWuIGpZmk D t s amp pp ygUOdGltIHNwYWuIGpZmk D t s amp pp ygUOdGltIHNwYWuIGpZmk D Articles tspann finding the best way around ccacbRemember always be demoing tspann using nifi as an smtp email test server acb Recent Talks Events utm medium member desktopMay Pulsar Summit Europe VirtualMay Big Data Fest Virtual June PM EDTCloudera Now Virtual internal campaign FY Q AMER CNOW Q WEB EP P amp cid HZLmyQAG amp internal link pJune NLIT Summit Milwaukee June NiFi Meetup Milwaukee and Hybrid July Hours to Data Innovation Data FlowOctober Hours to Data Innovation Data FlowCloudera EventsMore Events ToolsVisual Clean Images with AI Tim Spann |
2023-05-22 12:02:43 |
Apple |
AppleInsider - Frontpage News |
Unable to make a profit, Wistron is giving up iPhone assembly in India |
https://appleinsider.com/articles/23/05/22/unable-to-make-a-profit-wistron-is-giving-up-iphone-assembly-in-india?utm_medium=rss
|
Unable to make a profit Wistron is giving up iPhone assembly in IndiaApple supplier Wistron is selling its iPhone assembly factory in India because Apple s terms prevent it from making a profit in the region Wistron exits Apple India businessA report on May had suggested Wistron was gradually scaling down a majority of its operations in India and would to withdraw a significant portion of its presence from the country within the following year The move is now official according to India s Economic Times which spoke to company executives Read more |
2023-05-22 12:55:16 |
Apple |
AppleInsider - Frontpage News |
Family hit with $3,100 App Store bill after kid goes on Roblox spending spree |
https://appleinsider.com/articles/23/05/22/family-hit-with-3100-app-store-bill-after-kid-goes-on-roblox-spending-spree?utm_medium=rss
|
Family hit with App Store bill after kid goes on Roblox spending spreeA year old child spent over on Roblox via the family iPad charges applied after the child changed the account password Roblox in the App StoreStories of excessive spending in a game by a child regularly surface with parents complaining about the seemingly unjust charges In the latest iteration a year old managed to run up a bill of more than pounds on the game Roblox without her mother s knowledge Read more |
2023-05-22 12:01:12 |
海外TECH |
Engadget |
Venmo rolls out Teen Accounts with no-fee debit card and ATM access |
https://www.engadget.com/venmo-rolls-out-teen-accounts-with-no-fee-debit-card-and-atm-access-120038618.html?src=rss
|
Venmo rolls out Teen Accounts with no fee debit card and ATM accessParents with teenagers have a new option for managing their kid s spending cash Venmo has announced a feature it calls Venmo Teen Accounts This lets parents create accounts for minors aged to It comes with a Venmo Teen Debit Card which gives parents or guardians an insight into spending lets them send money and allows them to manage privacy settings According to Venmo over percent of parents are interested in using apps to help their children learn about money The company also claims that over percent of Gen Z want to have a conversation with an adult about managing personal finances The Venmo Teen Account should hopefully bridge that gap for many parents or guardians out there Venmo says that the Venmo Teen Account has no monthly fees and that the debit card will have no fee cash withdrawals at ATMs Of course the account will be able to send and receive money from family and friends Parents and guardians will be able to see friends list transaction history account balance and be able to manage the debit card s PIN lock and unlock it and block users from interacting with the account And since it s separate from the parent or guardian s account teens will be able to independently track their own spending and learn financial responsibility Venmo says that teen accounts will be eligible for direct deposit which is great for those with part time jobs Signing up for a teen account is pretty straightforward Parents or guardians will need to sign into their personal Venmo account and tap Me gt Your Name gt Create a teen account From there you ll need to add a name address and date of birth and choose a debit card style from a selection of a few colors Venmo Teen Accounts will be rolling out to select users in June of and will be available on a wider scale in the weeks following This article originally appeared on Engadget at |
2023-05-22 12:00:38 |
医療系 |
医療介護 CBnews |
少子化対策の財源確保に診療報酬抑制論-岸田首相「歳出改革の取り組み徹底」 |
https://www.cbnews.jp/news/entry/20230522205954
|
診療報酬 |
2023-05-22 21:40:00 |
海外ニュース |
Japan Times latest articles |
Hedge funds pushing for Japan returns get help from Tokyo exchange |
https://www.japantimes.co.jp/news/2023/05/22/business/tse-shareholder-proposals-record/
|
meetings |
2023-05-22 21:23:06 |
ニュース |
BBC News - Home |
Graeme Souness: Football legend to swim Channel for 'butterfly skin' girl |
https://www.bbc.co.uk/news/uk-scotland-highlands-islands-65664357?at_medium=RSS&at_campaign=KARANGA
|
condition |
2023-05-22 12:13:07 |
ニュース |
BBC News - Home |
Cyclist Mark Cavendish to retire at end of season |
https://www.bbc.co.uk/sport/cycling/65665546?at_medium=RSS&at_campaign=KARANGA
|
france |
2023-05-22 12:24:35 |
ニュース |
BBC News - Home |
Ex-Mirror chief regrets unlawful behaviour at newspapers |
https://www.bbc.co.uk/news/uk-65672888?at_medium=RSS&at_campaign=KARANGA
|
bailey |
2023-05-22 12:38:25 |
ニュース |
BBC News - Home |
Margaret Ferrier: Covid train trip MP loses appeal over Commons ban |
https://www.bbc.co.uk/news/uk-scotland-65671806?at_medium=RSS&at_campaign=KARANGA
|
constituency |
2023-05-22 12:20:13 |
ニュース |
BBC News - Home |
Blooms and blossoms: The Chelsea Flower Show in pictures |
https://www.bbc.co.uk/news/in-pictures-65669737?at_medium=RSS&at_campaign=KARANGA
|
adjustments |
2023-05-22 12:55:27 |
ニュース |
BBC News - Home |
Facebook fined €1.2bn for mishandling users' data |
https://www.bbc.co.uk/news/technology-65669839?at_medium=RSS&at_campaign=KARANGA
|
servers |
2023-05-22 12:02:18 |
ニュース |
BBC News - Home |
China bans major chip maker Micron from key infrastructure projects |
https://www.bbc.co.uk/news/business-65667746?at_medium=RSS&at_campaign=KARANGA
|
washington |
2023-05-22 12:42:48 |
ニュース |
BBC News - Home |
Racist abuse of Vinicius Jr shows society illness, says Guillem Balague |
https://www.bbc.co.uk/sport/football/65670233?at_medium=RSS&at_campaign=KARANGA
|
things |
2023-05-22 12:05:54 |
ニュース |
BBC News - Home |
Mancheser United's Hayley Ladd and Chelsea's Guro Reiten in WSL best goals |
https://www.bbc.co.uk/sport/av/football/65672244?at_medium=RSS&at_campaign=KARANGA
|
Mancheser United x s Hayley Ladd and Chelsea x s Guro Reiten in WSL best goalsWatch the best goals from this weekend s Women s Super League fixtures including a brilliant finish from Chelsea s Guro Reiten and Manchester United s Hayley Ladd scores from long range |
2023-05-22 12:47:49 |
ニュース |
Newsweek |
「ヘビは好きじゃないけどこれはひどい...」ニシキヘビをムチ同然に振り回して人を襲う男 |
https://www.newsweekjapan.jp/stories/world/2023/05/post-101700.php
|
|
2023-05-22 21:35:00 |
コメント
コメントを投稿