IT |
ITmedia 総合記事一覧 |
[ITmedia News] 「ポケモンGO Plus+」の気になるところ 保証なし、LEDまぶしすぎ でもオートスローは超便利 |
https://www.itmedia.co.jp/news/articles/2307/23/news056.html
|
itmedia |
2023-07-23 16:15:00 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
A* アルゴリズム |
https://qiita.com/Karin-Sugi/items/4e364a7263ee84575758
|
障害 |
2023-07-23 16:44:19 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
【Rails】バリデーションをスキップ |
https://qiita.com/reraise/items/7f649a65cb72409d659e
|
rails |
2023-07-23 16:39:16 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
【Rails】メモ化 |
https://qiita.com/reraise/items/d36842be24e0d682eebe
|
defpositionchiefpo |
2023-07-23 16:15:38 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
CircleCI + AWS(StepFunctions)でmigrationの成功を待つ |
https://qiita.com/kawashinji/items/6b9e41c0fba005198733
|
circleci |
2023-07-23 16:15:55 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
Ubuntuでdocker-compose |
https://qiita.com/gabakugik/items/d9158f01c48eb8c84e2c
|
dockercomposerailsubuntu |
2023-07-23 16:59:27 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
Ubuntuでdocker-compose |
https://qiita.com/gabakugik/items/d9158f01c48eb8c84e2c
|
dockercomposerailsubuntu |
2023-07-23 16:59:27 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
【Rails】バリデーションをスキップ |
https://qiita.com/reraise/items/7f649a65cb72409d659e
|
rails |
2023-07-23 16:39:16 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
【Rails】メモ化 |
https://qiita.com/reraise/items/d36842be24e0d682eebe
|
defpositionchiefpo |
2023-07-23 16:15:38 |
海外TECH |
DEV Community |
SOLID: Single Responsibility Principle With Examples |
https://dev.to/ggorantala/solid-single-responsibility-principle-with-examples-h0f
|
SOLID Single Responsibility Principle With ExamplesIn this article you will learn about the following What is SRP Importance of SRP in software developmentStrengthsWeaknessesTwitter Registration What is SRP The Single Responsibility Principle SRP is one of the five SOLID design principles that guide software development Definition A class or module should have only one reason to change The principle states that a class should have only one reason to change and one responsibility This principle is intended to promote modularity and help developers create easier code to understand modify and maintain In essence the SRP states that each class should have a single well defined responsibility and that responsibility should be encapsulated within that class This means that a class should not have multiple responsibilities as this can make it harder to understand and modify By following the SRP developers can create more maintainable and flexible code that is easier to work with over time The SRP is a fundamental principle in object oriented programming and it can significantly impact the quality and effectiveness of software development We will explore the SRP in more detail including how it works why it is important and how to apply it effectively in Java programming Importance of SRP in software developmentThere are several reasons why SRP is important in software development Enhances code readability Reading and understanding the code becomes easier when each class or module has a single responsibility This helps developers quickly understand the purpose of the class or module and its relationship with other parts of the system Increases code maintainability By breaking down complex functionality into smaller more focused modules SRP enables developers to make changes to the code more easily without affecting other parts of the system This means that maintenance and troubleshooting of the code become less time consuming and costly Facilitates code reuse Code that adheres to SRP is often more modular and reusable This means developers can easily reuse the code in other parts of the system or projects Improves system scalability Maintaining a single responsibility for each class or module becomes increasingly important as the codebase grows SRP ensures that the codebase remains scalable and can easily accommodate changes or new features without impacting the rest of the system Overall adhering to the Single Responsibility Principle improves the quality and maintainability of the codebase making it easier to manage test and deploy AdvantagesThe advantages of following the Single Responsibility Principle SRP include the following Better code organization and maintainability Improved readability and understanding of code Easier debugging and testing of code A higher degree of code reusability Facilitation of parallel development and implementation of new features Ability to make changes to code with less risk of introducing bugs DisadvantagesSome of the disadvantages of the Single Responsibility Principle SRP include the following Increased complexity as a system may require more classes to implement the same functionality Potential for over engineering leading to too much abstraction and unnecessary code Difficulties in determining the appropriate granularity of responsibilities Challenges in balancing the trade off between separating responsibilities and maintaining performance When programmers try to add features or new behaviour to a software product they frequently integrate everything within the current class When something needs to be changed later due to the complexity of the code the code refactor process is extremely time consuming and tedious The Single Responsibility Principle helps us create simple classes that perform just one task This helps make modifications or adding extensions to the existing code much more effortless Twitter Registration Using Single Responsibility PrincipleWe design Twitter registration software with the help of the single responsibility principle that contains a notification service database repository account service and execution class Let s implement the first design principle on Twitter registration flow Signup process on TwitterConsider a use case where a user wants to register with Twitter The steps Twitter takes to register are user are Twitter asks users to register with signup forms Twitter stores the user object in their database which contains User details email name password and other metadata etc Twitter sends a welcome message to the user Let us declare a class that does the above steps public class TwitterRegistration public void register step System out println Fill signup form step System out println Store account details in database step System out println Send a welcome message We are creating an account on Twitter and the three steps should be handled separately But the above class declared them all in a single TwitterRegistration class Isn t this a violation of SRP Also step of storing an object in the database requires additional work to open a connection with the database authenticate the handshake and store the user object This is insertion logic and should be handled separately The third step is sending out a welcome message to the user which should be handled by NotificationService separately Using the SRP principle we divide the above TwitterRegistration class into three different classes each having a single and only one responsibility Refactoring for SRPRefactoring TwitterRegistration the class gives Notification Serviceclass NotificationService public void sendNotification step System out println Send out welcome message Database handshakesclass AccountRepository public void createUser step System out println Auth Success System out println Store user data into database Account Registrationclass TwitterAccountRegister public void registerUser step System out println fill account internal details Finally after refactoring the above classes We first allow the TwitterAccountService to create a couple of objects for AccountRepository and NotificationService to register users with Twitter Execution Class or Main classpublic class TwitterAccountRegister public static void main String args TwitterAccountService service new TwitterAccountService service registerUser Account Registration Serviceclass TwitterAccountService AccountRepository repository new AccountRepository NotificationService notificationService new NotificationService public void registerUser step System out println fill account internal details repository createUser notificationService sendNotification Notification Serviceclass NotificationService public void sendNotification step System out println Send out welcome message Database handshakesclass AccountRepository public void createUser step System out println Signup Success Registered System out println Store user data into database Outputs fill account internal detailsSignup Success RegisteredStore user data into databaseSend out welcome message In above TwitterAccountService is doing all three tasks The primary responsibility is to fill in account details in account details and delegate the other responsibilities to other classes Finally we know many teams work on the same software product By following the SRP principle if we see file changes in Github for a file named TweetAnalytics we can be sure that the changes incorporated are related to analytics This helps version control with ease ConclusionIn conclusion the Single Responsibility Principle SRP is a software design principle that states that every class should have only one reason to change Following SRP makes code easier to understand maintain and extend It reduces the risk of introducing bugs and makes it easier to test individual components in isolation SRP encourages the separation of concerns making the code more modular and scalable This principle is one of the five SOLID principles of object oriented design and is an important aspect of creating clean maintainable and scalable code |
2023-07-23 07:40:20 |
海外TECH |
DEV Community |
LeetCode 2790 (Hard). Maximum Number of Groups With Increasing Length. Solution of the day. O(NlogN). Math. |
https://dev.to/sergeyleschev/leetcode-2790-hard-maximum-number-of-groups-with-increasing-length-solution-of-the-day-on-logn-math-4lh
|
LeetCode Hard Maximum Number of Groups With Increasing Length Solution of the day O NlogN Math DescriptionYou are given a indexed array usageLimits of length n Your task is to create groups using numbers from to n ensuring that each number i is used no more than usageLimits i times in total across all groups You must also satisfy the following conditions Each group must consist of distinct numbers meaning that no duplicate numbers are allowed within a single group Each group except the first one must have a length strictly greater than the previous group Return an integer denoting the maximum number of groups you can create while satisfying these conditions Example Input usageLimits Output Explanation In this example we can use at most once at most twice and at most five times One way of creating the maximum number of groups while satisfying the conditions is Group contains the number Group contains the numbers Group contains the numbers It can be shown that the maximum number of groups is So the output is Example Input usageLimits Output Explanation In this example we can use at most twice at most once and at most twice One way of creating the maximum number of groups while satisfying the conditions is Group contains the number Group contains the numbers It can be shown that the maximum number of groups is So the output is Example Input usageLimits Output Explanation In this example we can use both and at most once One way of creating the maximum number of groups while satisfying the conditions is Group contains the number It can be shown that the maximum number of groups is So the output is Constraints lt usageLimits length lt lt usageLimits i lt ApproachSorting the usageLimits array The first step is to sort the input array usageLimits in ascending order Sorting takes O NlogN time complexity where N is the length of the usageLimits array Tracking the total and count The total variable is used to keep track of the cumulative sum of elements in the sorted usageLimits array The count variable represents the number of groups created so far that satisfy the conditions Iterating through the sorted array The function iterates through the sorted array using a for loop For each element at index i it adds the value to the total The purpose of the total is to keep track of the total number of allowed occurrences across all groups formed so far Checking the conditions After adding an element to the total the function checks whether the current total value is greater than or equal to the required sum for the next group The required sum for the next group is calculated as count count Here count represents the next group s length and count represents the sum of elements from to count If the total is greater than or equal to this required sum it means that we can create another group satisfying the conditions Incrementing the count If the condition in step is true the count is incremented indicating that another group can be formed Returning the result After iterating through the entire sorted array the count variable will represent the maximum number of groups that can be created while satisfying the conditions The function returns this count ComplexityTime complexity O N logN The time complexity of this solution is dominated by the sorting step making it O N logN where N is the length of the input array usageLimits The rest of the operations involve simple arithmetic and comparisons which take linear time Therefore the overall time complexity of the function is O NlogN Code Swift class Solution func maxIncreasingGroups usageLimits Int gt Int var sortedLimits usageLimits sorted var total var count for i in lt sortedLimits count total sortedLimits i if total gt count count count return count Sources GithubContactsI have a clear focus on time to market and don t prioritize technical debt And I took part in the Pre Sale RFX activity as a System Architect assessment efforts for Mobile iOS Swift Android Kotlin Frontend React TypeScript and Backend NodeJS NET PHP Kafka SQL NoSQL And I also formed the work of Pre Sale as a CTO from Opportunity to Proposal via knowledge transfer to Successful Delivery ️ startups management cto swift typescript databaseEmail sergey leschev gmail comLinkedIn LeetCode Twitter Github Website Reddit Quora Medium sergeyleschev️PDF Design Patterns Download |
2023-07-23 07:34:38 |
海外TECH |
DEV Community |
Brush up your CSS knowledge 🚀 Part[2 of 2] |
https://dev.to/ankur0904/brush-up-your-css-knowledge-part2-of-2-4hff
|
Brush up your CSS knowledge Part of This is a follow up blog of this IntroductionWelcome to this blog This blog is for beginners who just started the web development journey or professionals who just wanted to revise their CSS knowledge We will learn the essentials of CSS Let s get started One more thing for this blog I have created a website which helps me for the demonstration purpose As we have learned some important topics in the previous blog This is a follow up blog in which we will learn more about the CSS Layout of CSSThe CSS layout helps you to decide where the particular element of HTML will be positioned on the webpage This is a very important part that deals with the overall appearance of elements in a webpage There are many CSS property you can use for the layout purpose but in this blog we will cover the simple one position property CSS PositionFor the demonstration purpose I have created a website If you look at the website You can see there are some boxes with different different colours How those boxes are made These are a div element of HTML div in simple words you can think of it box whose default value is nothing which means no colour no height no width etc I have created these divs with the help of these lines of code HTML lt div class div one gt lt div gt CSS div one height px width px background color yellow Similarly I have created three divs with different colours Now time to learn about the position property of CSS Static PositioningStatic position means all the elements will follow the general flow of HTML The general or normal flow of HTML allows the element to go into the webpage from top to bottom like thisElement Element Element Not like this Element Element Element In the demonstration website you will check here how the div are stacked to each other The HTML and CSS code is as follows lt body gt lt h gt Hello world lt h gt lt div class div one gt lt div gt lt div class div two gt lt div gt lt div class div three gt lt div gt lt body gt div one height px width px background color yellow position static div two height px width px background color greenyellow position static div three height px width px background color red position static You will notice that if you remove position static this line then nothing will happen because this is the default behaviour of HTML Fixed PositioningThis property position fixed help us to fix the position of any HTML element means if you scroll the screen then the position of this element would not change like it was changing in other positioning And the element gets out of the general flow of HTML which is from top to bottom CSS div one height px width px background color yellow position fixed You can try this on the live demo By doing this the given div goes on top of the following HTML elements This can be fixed in many ways but we will not cover this in this blog Note Fixed positioning does take the element completely out of the flow of HTML Relative PositioningThis helps us to position the element with respect to the normal flow or default flow of the HTML of that element div one height px width px background color yellow position relative margin top px margin left px div two height px width px background color greenyellow div three height px width px background color red Notice in class div one we have set the position relative and also added some margin margin top px margin left px margin you can relate margin by the external spacing of an element This CSS property help to set the position of the HTML element div in this case relative to its normal position of general HTML flow Check the live demo here Note Relative positioning doesn t take the element completely from the flow of HTML Absolute PositioningThis helps us to position the element with respect to the nearest parents or ancestors Let s understand this via code lt body gt lt h gt Hello world lt h gt lt div class parent gt lt div class div one gt lt div gt lt div class div two gt lt div gt lt div class div three gt lt div gt lt div gt lt body gt Notice we have created a parent or ancestor div with class parent and nested the remaining div as a child inside the parent For making the position absolute we have to make the parent positioning relative and any one child or all children depending on your requirements positioning absolute Let s have a look at the CSS code parent position relative div one height px width px background color yellow position absolute right px div two height px width px background color greenyellow div three height px width px background color red Notice at div one we have added a CSS property right px this means the distance between the parent and the div with the position absolute to the right is px Please have a look at the demonstration live website to relate it Note Absolute positioning does take the element completely out of the flow of HTML You got it You revised a lot of fundamentals for the CSS Thanks for reading till the end If you have any feedback the comment section is yours Till then let s grow together CodeContact me ankursingh gmail com LinkedIn Twitter |
2023-07-23 07:19:24 |
ニュース |
BBC News - Home |
Spain faces stark left-right divide in hot summer vote |
https://www.bbc.co.uk/news/world-europe-66258206?at_medium=RSS&at_campaign=KARANGA
|
coalition |
2023-07-23 07:18:41 |
ニュース |
BBC News - Home |
Sweden 2-1 South Africa: Amanda Ilestedt scores late winner |
https://www.bbc.co.uk/sport/football/66281723?at_medium=RSS&at_campaign=KARANGA
|
wellington |
2023-07-23 07:16:42 |
ニュース |
BBC News - Home |
Women's World Cup 2023: Late Sweden winner earns opening win over South Africa - highlights |
https://www.bbc.co.uk/sport/av/football/66265183?at_medium=RSS&at_campaign=KARANGA
|
Women x s World Cup Late Sweden winner earns opening win over South Africa highlightsWatch highlights as Sweden s Amanda Ilestedt scores a late winner to lead her side to victory over South Africa at the Fifa Women s World Cup in Wellington |
2023-07-23 07:42:12 |
ニュース |
BBC News - Home |
Manchester United 2-0 Arsenal: Red Devils win New Jersey friendly |
https://www.bbc.co.uk/sport/football/66280991?at_medium=RSS&at_campaign=KARANGA
|
jersey |
2023-07-23 07:27:15 |
コメント
コメントを投稿