clean-code | projeto de textos de análise do livro clean code de robert | Runtime Evironment library
kandi X-RAY | clean-code Summary
kandi X-RAY | clean-code Summary
Este repositório tem como ideia principal servir como base para um possível TCC. Farei um breve resumo do livro, uma síntese da maioria de suas ideias e postarei aqui.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Generate primes
clean-code Key Features
clean-code Examples and Code Snippets
Community Discussions
Trending Discussions on clean-code
QUESTION
Input validation is a business logic so we should hide this process in the domain layer. as discussed here
I do it like this
Login validator
...ANSWER
Answered 2022-Feb-09 at 07:46My Question: What if I have a large form (eg:15 fields), Should I create a failure class for each of them? Is there a better way to handle the validation?
Every error that can occur must be identifiable. Either through dedicated classes, failure codes or constants. Which one you choose depends on the error context information that you want to provide to clients.
I also wouldn't put messages in the failure object, because it is up to a presenter to choose a presentation for a error type. The way an error is presented to the user highly depends on the user interface. Maybe an error doesn't need a string, it is just presented as an icon or a colored marker and so on. The interactor should not create language specific strings. This is part of the user interface.
In simple cases you might only need an error code or constant like 401
and the presenter converts it to Login failed
. Of course you can use a common error object for this cases too.
class Failure { int code; }
In other cases you might want to display a more detailed error message like E-mails under the domain '@somedomain.com' are not allowed to login.
. In this cases you should use an error object instead of only a simple code to provide details. E.g.
class LoginDomainFailure { String localPart; String domainName }
A presenter can then use this information to generate a failure string or present the error in some other way, e.g. highlighting the domain name in the input field or whatever you can imagine.
QUESTION
I have following entities
...ANSWER
Answered 2021-Sep-26 at 16:15I am having a hard time understanding why you need the second query. With the first one, you would get a set of Role
s. The Role
object already contains a set of Privilege
s which you can simply retrieve using the getter method as follows:
QUESTION
I am having trouble wiring up identity into Blazor server with ASP.NET Core identity. Specifically getting the correct logged in state in Blazor pages (while I am getting them from the Blazor pages).
I think it's related to some of the startup being initialized in another project - but not sure how to debug it or what the solution is to be able to get the logged in state correctly.
Reproduction steps and link to GH repo below as a POC.
Background
I'm porting over the clean-code project by JasonTaylor from Angular / ASP.NET Core to a Blazor server project with ASP.NET Core Identity.
Issue
The application runs up and I can browse the pages when I register I can see logged-in state in the identity-based default pages but in the Blazor pages that use the AuthorizeView
(e.g. LoginDisplay.razor
) it's not aware of being authorized.
Startup in the Blazor project:
...ANSWER
Answered 2021-Jun-10 at 08:10This was an issue with mixing IdentityServer and ASP.net identity.
By removing Microsoft.AspNetCore.ApiAuthorization.IdentityServer
and the use of base class from ApiAuthorizationDbContext
back to IdentityDbContext
resolved this.
QUESTION
I'm trying to implement a functionality where user can select type of view on Combobox. Based on selection either DataGrid or ListView will display given data.
My question here is: What is the correct way to implement this?
Do I set Visibility property on DataGrid and ListView based on selection of the Combobox or is there another "cleaner" way to do this (referring to clean-code principles)?
...ANSWER
Answered 2021-May-21 at 12:46You could use a ContentControl
with a Style
that triggers on the selected value in the ComboBox
, e.g.:
QUESTION
In my Rails API project using graphql-ruby
, I have two Mutations that stands for two slightly different flows. They share a lot of arguments and I would like to keep it DRY, avoiding repeating the similar arguments, so when we change them, we don't accidentally forget to change the other.
I was wondering how I could solve this problem without falling into the boolean/flag trap resulting in a tangled implementation.
I could use concepts of inheritance or composition, but how to do it ?
...ANSWER
Answered 2021-Feb-06 at 03:38A good way I found is using mixins.
With the help of SuperModule
or ActiveSupport::Concern
, I think it yields a pretty clean code.
app/graphql/mutations/create_thing.rb
QUESTION
class SearchInput extends React.Component {
constructor(props) {
super(props);
this.searchInputRef = React.createRef(); // 👈️ LOOK HERE
}
onFormSubmit = (e) => {
e.preventDefault();
// const query = e.target.querySelector("#searchInput").value; // 👈️ LOOK HERE
const query = this.searchInputRef.current.value;
console.log(query);
};
render() {
return (
{this.props.label}
);
}
}
...ANSWER
Answered 2021-Feb-04 at 09:39At first // 👈️ LOOK HERE
,
You could have a function to create ref, to distinct them i prefer an id
.
QUESTION
I have a relatively simple web app that I'm creating as a bookshelf and I want the user to be able to drag and drop books between the bookshelves. It works exactly as I want when I drop a book to the "right" side of the existing books in one of the bookshelves. The book that has been dragged and dropped is added to the shelf.
Where it isn't working is when I drop a book on top of an existing book. When I do that, the book is removed from the existing shelf -- but it disappears totally instead of being added to the targeted bookshelf as I desire. Its unclear to me why this is.
See here: https://mainstringargs.github.io/bookshelf-data/test.html
(I'm using Firefox, if that is relevant)
Relevant source code is here (raw html): https://github.com/mainstringargs/bookshelf-data/blob/master/test.html
Note: This was originally generated via jekyll in github, but since this problem is not jekyll centric, I'm not including that source code detail.
I largely followed this guide for how to implement drag and drop:
https://www.w3schools.com/html/html5_draganddrop.asp
The relevant javascript code is below. The 'drop' function is intended to drop the relevant list item to the new list.
...ANSWER
Answered 2021-Jan-11 at 09:32The issue is that when you are dropping on top of an existing book, the target of the event is the img
element of the existing book. When you drop on the right side of a list, the target of the event is the ul
element which works correctly.
This answer will solve your issue: https://stackoverflow.com/a/28203782/9262488
Please see this fiddile: https://jsfiddle.net/4gsrpv31/
Or you could check the target of the event and append to its parent node if it is an img
element as below:
QUESTION
My component is supposed to retrieve the data for courses when the component mounts. The problem that I have is that whether I use the course Id or the course title as the key, I get the following error:
index.js:1 Warning: Each child in a list should have a unique "key" prop.
I have looked through the react docs, here on Stack Overflow, and tried different ways to get it to work. The only way I can get it to partially work is by adding an index as a parameter for map. When I use this method, I run into another problem and that is, it stops after the first iteration, even though there are 10 items. How can I fix this?
Here is my code:
CoursesPage.js
...ANSWER
Answered 2020-Aug-27 at 05:10The issue is here:
QUESTION
I developed a software which can be automatically updated, so I need external-placed config file/files. For now I use json file to store user-input variables like user name etc. But I am not sure how the program itself should be controlled. I mean things like checking if program is opened for first time after update to know if update notes should be shown, what functions were already used etc. For now I am doing it with things like:
...ANSWER
Answered 2020-Mar-16 at 09:20Given that you need to have config information stored in a file. If you choose to have that information in a file that contains a json record then it is the most convenient if the file is used internally and updating and reading the record in the file is easy (treat it as a dict)
However, if you want a more universal config.ini reader then you can go with ConfigParser class which you can use directly or create your own wrapper
class MYConfig_Parser(ConfigParser):
so that you can check stuff in the constructor like if mandatory entries are available etc before processing the entries.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install clean-code
You can use clean-code like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the clean-code component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page