投稿時間:2022-02-15 20:27:47 RSSフィード2022-02-15 20:00 分まとめ(37件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT 気になる、記になる… Appleの整備済み商品情報 2022/2/15 https://taisy0.com/2022/02/15/152067.html apple 2022-02-15 10:24:40
TECH Engadget Japanese 首の筋肉を奥からほぐす。小型&ポータブル、服で隠せるEMSネックケア温熱器「HX-06」 https://japanese.engadget.com/ems-neck-care-102516169.html 2022-02-15 10:25:16
ROBOT ロボスタ NVIDIA Jetson搭載のコンパクトPC「ZED Box Xavier NX」「ZED Box TX2 NX」アスクが発表 Stereolabs社製 https://robotstart.info/2022/02/15/stereolabs-jetson-pc-ask.html NVIDIAJetson搭載のコンパクトPC「ZEDBoxXavierNX」「ZEDBoxTXNX」アスクが発表Stereolabs社製シェアツイートはてブ株式会社アスクはStereolabs社製のNVIDIAJetson搭載コンパクトPC「ZEDBoxXavierNX」および「ZEDBoxTXNX」を発表した。 2022-02-15 10:02:21
Linux Ubuntuタグが付けられた新着投稿 - Qiita Node-RedでOpenCVするまでのメモ https://qiita.com/NWLab/items/0b7769a1289994dc53cf NodeRedでOpenCVするまでのメモ色々試行錯誤が必要だったのでメモ環境UbuntuLTSNodeRed使いたいのはこちらInstallopencvnodejsにOpenCVの自動BuildScriptが入っているのですが失敗するので、別々にインストールします。 2022-02-15 19:20:07
AWS AWSタグが付けられた新着投稿 - Qiita AWS認定 MLS-C01に合格しました(2022/02/15) https://qiita.com/oddgai/items/ef709bb5112d67fb4e25 受験前の経験・知識など新卒年目、データエンジニア・データサイエンティスト機械学習は専門ではないが、学生時代に授業などで触ったことはあるのでキーワードはそこそこ覚えている少し前に簡単な画像分類アプリも作ったAWS系の業務経験はあまりない日常的にSQLRedShiftとSは使うが、管理者ではないのでアクセス権などはよくわからないSageMakerは一瞬だけ触ったことがあるSAACを半年前に合格したので、AWS全体のざっくりとした知識はある使った教材このような流れで勉強しましたが、AWS公式教材は最初のほうに触ったほうがよいと思いましたkoiwaclubに解答ミスがあり、直前で公式模試を解いて間違いに気づきました。 2022-02-15 19:59:52
Docker dockerタグが付けられた新着投稿 - Qiita 【Vagrant】Windows10でVirtualBox+Vagrant+Ubuntu 21.04でDocker環境を構築する https://qiita.com/nata_water/items/23d3d7a3ab39dfb51e87 無償利用の条件lessthanemployeesANDlessthanmillioninrevenue人未満の従業員と万ドル未満の収益ProTeamBusinessを契約し利用することも考えられますが、社内稟議を通すのは難しい。 2022-02-15 19:28:30
Docker dockerタグが付けられた新着投稿 - Qiita NextcloudにOnlyOfficeとElasticsearchを組み込んで最強のオンラインストレージサーバを構築する https://qiita.com/higebobo/items/271ff6b9454d8c5b6114 GNUMakeが使えない場合はMakefileのタスクを参照してコマンドラインから実行すればよいmakeupしばらくすると完了するのでブラウザでNextcloudにアクセスするデフォルトではhttplocalhostユーザ名やパスワードは適当に入力して「ストレージとデータベース」をクリック環境変数で設定したデータベースの情報を入力。 2022-02-15 19:16:44
Git Gitタグが付けられた新着投稿 - Qiita 【git】ひっかかったことと解決法一覧 https://qiita.com/ronnieQQI9/items/3502541ca7b4a86dcfd4 もしかしてgitaddがやりたかったそれだったら実行してみてね」自分的ひっかかりポイント…最後の「」忘れの凡ミス④errorfailedtopushsomerefstoURLリモートにアップ後、SQL文のドキュメントファイル入れるのを忘れていたことに気づきデータ更新しようとした際に発生。 2022-02-15 19:12:27
海外TECH DEV Community Declarative Data Validation with Functional Programming and Rule-Based Approach https://dev.to/bespoyasov/declarative-data-validation-with-functional-programming-and-rule-based-approach-22a4 Declarative Data Validation with Functional Programming and Rule Based ApproachI ve always found client data validation to be a challenge Self written validators code easily rolls into an unreadable mess and validation libraries sometimes carry infrastructural limitations that can complicate their integration In this post I want to show you a principle I use in my projects that makes validation easier and helps to write maintainable and extensible code To illustrate this approach I ve prepared a sample application the Mars colonizer application form The example is pretty straightforward but I tried to put together frequent examples of different data types phone mail numeric value date password validation and interdependent fields You can find the application and its source code by the links below Sample ApplicationSources on GitHubIn this app I purposely didn t use HTML attributes for form validation to increase the amount of code This is better to see the benefits and problems of the principle Problem with Client ValidationThe main problem with data validation on the client is that the rules by which we validate the data are too closely intertwined with the peculiarities of the user interface Data validation itself is often trivial and even interdependent fields don t make the task much more difficult But how we show the results of validation to the user and what events should be triggered during or after validationーdoes Different projects have different validation requirements For example validation might be reactiveーso that the form is checked as it is filled out Sometimes on the contrary the form must be validated after it is completely filled out Or the form may show additional fields after a value is entered When dealing with different requirements it becomes difficult to separate the interface logic from the domain logic but it is this separation that helps keep the complexity of the code under control Domain UI and Infrastructure LogicBy the domain logic we will mean validation rules that are dictated by business requirements Each of these rules has a reason to be in the real world For example if the phone number or email is incorrect we won t be able to contact the user This circumstance is the reason for checking the phone or email The UI logic is what the user sees on the screen This most often has nothing to do with the real world Interface logic is responsible only for interface changes It knows nothing about the rules themselves but it knows how to show the user an error or how to highlight an invalid field An example would be the appearance and disappearance of interdependent fields In the real world there is no reason to hide any fields On paper forms they don t hide fields but explain in a text which field under which conditions to fill But on the screen we want and can simplify the user s life so we adapt the interface by hiding and showing the right fields The infrastructural logic is the logic that directly runs data through the rules We can think of it as a “validation service to which we feed rules and data It checks if the data is valid We ll explore this logic in more detail when we get to the example but for now let s talk more about the main thingーvalidation rules Power of CompositionLet s look at the skeleton of data validation It is based on checking the value against some criterion The criterion is the standard against which we check the value In most cases checking will boil down to comparing a primitive value to some “standard value Such checks are best described as pure functions that take a value as input and tell us if it is valid Criteria as FunctionsPure functions are functions that produce no side effects and always give the same result with the same input data If such a function returns a Boolean value we can call it a predicate const isGreaterThan value gt value gt Predicates are similar to validation rules they take a value and answer whether the value is “okay or “not okay Such functions are predictable testable and declarativeーthat is they describe the result we want to get Pure functions are convenient to describe checks because we can specify the criterion to be checked right in the name And since they are predicates i e they always return a boolean value we won t need to look at their code to understand how they work For example if when validating a string we check that it contains a point and isn t shorter than characters we can express it in code with two such functions const containsPointCharacter str gt str includes const longerOrEqualThan str gt str length gt Each individual function checks one criterion one “feature of the passed value If we want to check both criteria at the same time we can call both functions and check that both functions returned true const value lol kek cheburek containsPointCharacter value amp amp longerOrEqualThan value trueOr write a function that combines the functionality of these two and checks the value against both criteria const isValid value gt containsPointCharacter value amp amp longerOrEqualThan value This way we can assemble more complex rules from simpler onesーcompose them Composition of RulesIn a general sense the composition is making complex things from simpler things Here we compose big complex checking rules from small simple ones The simpler and more intuitive the mechanism for making complex rules the fewer mistakes we will make when describing them We can reduce any complex rule to a set of simple ones using binary logic For example we can use the operation AND amp amp to check all criteria at once and OR to check at least one This is similar to the algebraic type system where we can make complex types and simple types using AND and OR operations Duplication and Reusable CodeSince each function checks one criterion one feature they are abstract enough to be part of several rules at once For example we can use the isString function in both phone and mail checks const isString x gt typeof x string If we find the same criteria in the validation rules we can reuse functions already written to reduce duplication Next we ll see in examples that the fight against duplication doesn t end there We will look at how you can bring template actions into “sup programs All according to SICP Application ExampleLet s move on from theory to practice and write a sample application from scratch We ll create the validation for the Mars colonizer application form I won t show the code for the markup the styles and most of the DOM handling because it s not that important for this topic But you can always see the source code on GitHub or look it up in the running application This example is intentionally simple In real projects validation will be more complicated and relations between rules may be more intricate But it s much easier to demonstrate new concepts using simple examples So let s get to work Defining the RulesLet s start with the “core of the checkーthe rules Assume that we have already figured out all the business requirements and written them down Let s say the requirements are phone and email must be in the correct format the phone must start with a “ i e it must be international the user must be at least years old and not older than the user should choose the specialty from the list offered if their specialty is not in the list the user should specify it in the field below the string length in this case should not exceed characters the work experience must be years the passcode shouldn t be shorter than characters have at least one uppercase letter and at least one digit All of these rules are part of the domain because there is a reason for each of them to exist in the real world Phone and email are needed to contact the user Age is between and ーso that colonizers can better survive on board and the new planet The specialties listed have higher priority because colonizers need biologists engineers and psychologists the most etc Each of these rules we already can turn into a predicate but first I suggest looking at the data we are working with and modeling it Modeling a Form TypeI will be using TypeScript in the code examples Most of the examples will be almost identical to JavaScript code but if you still feel unsure I recommend reading TypeScript Handbook So we will represent the data from the form as the ApplicationForm type Each field of this type will be a field in the form itself We will represent field types as wrapper types to avoid obsession with primitives types tsexport type ApplicationForm name ApplicantName phone PhoneNumber email EmailAddress birthDate BirthDate photo UserPhoto specialty KnownSpecialty customSpecialty UnknownSpecialty experience ExperienceYears password Password Let s design the wrapper types for the fields types tstype ApplicantName string type PhoneNumber string type EmailAddress string type BirthDate DateString type UserPhoto Image type KnownSpecialty engineer scientist psychologist type UnknownSpecialty string type ExperienceYears NumberLike type Password string The types NumberLike DateString and Image are abstract enough to put them in a separate module Create globally accessible annotations in shared kernvel d ts and add these types there Besides them let s add some auxiliary types that we will need in the future shared kernel d ts Optional value helpers type Nullable lt T gt T null type Optional lt T gt T undefined Array wrapper type List lt T gt T Since HTML inputs return strings we re going to need to have a type that reflects our intent to get a number type NumberLike string type Comparable string number Improving the readability of the code and adding details about the domain type DateString string type TimeStamp number type NumberYears number type LocalFile File type Image LocalFile Shared kernel is code and data whose dependency does not increase coupling between modules I wrote more about this in the post about clean architecture on the frontend There I refer you to another postー DDD Hexagonal Onion Clean CQRS How I put it all together I recommend you read it too We describe the form as ApplicationForm We will use this type in the form validation rules as a signature for the input data Implementing the Validation CriteriaWe will implement the rules as predicate functions The functions will be pure and depend only on input data It means that they will know nothing about the UI All rules will take a form object as input and return a boolean value That is they will provide the same “public API which we can represent as a signature ApplicationForm gt booleanAll other application logic will depend on these rules not the other way around This way we isolate the rules logic and decouple it from the rest of the code Let s start with the name By requirement it just has to exist There are no additional restrictions so we ll check the value for truth validation tsexport const validateName name gt name Note that the function is quite concreteーit takes a form object as input from which it gets the name However checking for truthiness is a fairly common operation We can put such a check into a separate function to reuse it in the future utils tsexport const exists lt TEntity gt x TEntity gt x validation tsexport const validateName name gt exists name This is how we separate levels of abstraction We keep the repeating operation in the exists function and use it in the specific case of name validation Abstraction allows us to “remove unnecessary details When checking a name we don t care how we check for its existence We “sweep the check details into a separate function and rely on it as a wholeーas a single action This makes the code reusable and readable Let s move on to the email Suppose our email validation rule consists of two criteria “the string must contain and “the string must contain a period We can concatenate such criteria with an AND validation tsexport const validateEmail email gt email includes amp amp email includes With the phone number it s more interesting There are two criteria there too “international format and “allowed characters only We can write it like this validation tsconst validatePhone phone gt phone startsWith amp amp phone search d s g lt But such code smells a bit because it is hard to understand why there is a “ here and why we are looking for this particular pattern Instead we can break the “features into functions and their names declare the intention validation tsconst onlyInternational phone gt phone startsWith const onlySafeCharacters phone gt phone search d s g lt Now you may notice that the onlySafeCharacters function has one more operation that will come in handy in the futureーsearch by string Let s put this operation into a function and name it clearly too utils tsexport const contains value string pattern RegExp gt value search pattern gt validation tsconst onlySafeCharacters phone gt contains phone d s g We could have also put the regular expression in a variable but right now we don t need it The task of “explaining the intent is solved by the name of the function So we can leave it as is To check the date of birth we use the criteria “date as a string with a valid format and “user s age between and utils tsexport const inRange value Comparable min Comparable max Comparable gt value gt min amp amp value lt max export const yearsOf date TimeStamp NumberYears gt new Date getFullYear new Date date getFullYear validation tsconst MIN AGE const MAX AGE const validDate birthDate gt Number isNaN Date parse birthDate const allowedAge birthDate gt inRange yearsOf Date parse birthDate MIN AGE MAX AGE Specialty check refers to different interdependent fields if the user has selected a specialty from the list use it and if notーuse an additional field and check that the length of its value is not more than characters validation tsconst MAX SPECIALTY LENGTH const DEFAULT SPECIALTIES List lt KnownSpecialty gt engineer scientist psychologist const isKnownSpecialty specialty gt DEFAULT SPECIALTIES includes specialty const isValidCustom customSpecialty custom gt exists custom amp amp custom length lt MAX SPECIALTY LENGTH Notice that we have no problem with interdependent fields Functions have enough data and context to check such fields because we re giving the entire form object as input not field values individually We can think of this object as a unit of information transfer We sort of pack into it everything we might need to check the form For interdependent fields such an object turns out to be self sufficient The main thing is to make sure that the data inside relates to the same task and that the level of abstraction is the same for all fields Next experience validation The rules require colonists to have at least years of experience in their field Let s write it that way but don t forget that inputs return strings and convert the value to a number const isNumberLike experience gt Number isFinite Number experience const isExperienced experience gt Number experience gt MIN EXPERIENCE YEARS The isNumberLike function is abstract enough to make it a separate function that would take a primitive like exists But we ll skip that this time to avoid extra code Finally we check the password It must be at least characters long contain at least one uppercase letter and at least one number const atLeastOneCapital A Z g const atLeastOneDigit d gi const hasRequiredSize password gt password length gt MIN PASSWORD SIZE const hasCapital password gt contains password atLeastOneCapital const hasDigit password gt contains password atLeastOneDigit Notice how the combination of the contains function and specific regular expressions makes the code look like a sentence When we properly divide the levels of abstraction and don t mix them up the details of the implementation don t get in the way of understanding the intention That s why we separate the more abstract operations into separate functions and give them clear namesーthis is how we make the intentions clearer Composing Validation RulesAt this point we ve prepared the data validation criteria Now we can build rules from them to validate the entire form In some cases the criterion is itself a rule as in the case of name or email We can use such functions without any additional operations In other cases we need to combine the criteria into more complex rules like a password for example const validatePassword form ApplicationForm gt hasRequiredSize form amp amp hasCapital form amp amp hasDigit form It is easy to see that a similar arrangement will be repeated in other cases const validateBirthDate form ApplicationForm gt validDate form amp amp allowedAge form const validateExperience form ApplicationForm gt isNumber form amp amp isExperienced form …But we can put this operationーcombining different criteriaーinto a function Then we won t have to call the criterion functions by hand and pass them arguments We can automate this and make the intention more explicit Let s write functions that compose the criteria into rules services validation tsexport function all rules return data gt rules every isValid gt isValid data export function some rules return data gt rules some isValid gt isValid data Note that these composer functions don t care what rules they take as input The point of composers is to take a list of rules and run some value through them We have successfully extracted a repeating set of actions that is we have again separated levels of abstraction To prove that such composers can work with any rules let s add type signaturesーwe will see that these functions can be made generic services validation tsexport type ValidationRule lt T gt data T gt boolean type RequiresAll lt T gt ValidationRule lt T gt type RequiresAny lt T gt ValidationRule lt T gt export function all lt T gt rules List lt ValidationRule lt T gt gt RequiresAll lt T gt return data gt rules every isValid gt isValid data export function some lt T gt rules List lt ValidationRule lt T gt gt RequiresAny lt T gt return data gt rules some isValid gt isValid data And now we can use composers to assemble the validation criteria into rules validation tsconst phoneRules onlyInternational onlySafeCharacters const birthDateRules validDate allowedAge const specialtyRules isKnownSpecialty isValidCustom const experienceRules isNumberLike isExperienced const passwordRules hasRequiredSize hasCapital hasDigit export const validatePhone all phoneRules export const validateBirthDate all birthDateRules export const validateSpecialty some specialtyRules export const validateExperience all experienceRules export const validatePassword all passwordRules We can already use these rules for example if we want to validate a specific field But we can go further and build a validator for the whole form using the same linkers Building the Whole Form ValidatorRules have the same signature as criteria so we can use all and some to compose rules into even more complex rules For example to validate the form from the example we can write validation tsexport const validateForm all validateName validateEmail validatePhone validateBirthDate validateSpecialty validateExperience validatePassword And the validateForm function will check that each rule no longer a criterion but a whole rule is satisfied Validation ErrorsThe function validateForm tells us if the form is valid or not But it cannot tell you which particular field has errors and which rule has failed Filling out a form like this would be a nightmare for the user so let s fix that Designing Validation ResultFirst of all let s think about in what form we want to get the result I thought an object with two fields would be sufficient valid and errors The first will answer the question if the form is valid and the second will contain error messages for each invalid field services validation tsexport type ErrorMessage string export type ErrorMessages lt TData gt Partial lt Record lt keyof TData ErrorMessage gt gt export type ValidationRules lt TData gt Partial lt Record lt keyof TData ValidationRule lt TData gt gt gt type ValidationResult lt TData gt valid boolean errors ErrorMessages lt TData gt Errors and rules will then be displayed as objects with the keys being form fields and the values being error messages and rule functions respectively validation tstype ApplicationRules ValidationRules lt ApplicationForm gt type ApplicationErrors ErrorMessages lt ApplicationForm gt const rules ApplicationRules name validateName email validateEmail phone validatePhone birthDate validateBirthDate specialty validateSpecialty experience validateExperience password validatePassword const errors ApplicationErrors name Your name is required for this mission email Correct email format is user example com phone Please use only “ “ “ “ and a whitespace birthDate We require applicants to be between and years specialty Please use up to characters to describe your specialty experience For this mission we search for experience years password Your password must be longer than characters include a capital letter and a digit Again the objects of errors and rules can be any objects so we can describe them as generics The validator itself won t care about this eitherーits task will be to run each field through the corresponding rule and write the result That s why we won t create a single validator but rather a factory Creating Validator FactoryA factory is an entity that creates other entities In our case it s a function that will create functions We will again put the same type of actions into a “superprogram the createValidator function services validation tsexport function createValidator lt TData gt rules ValidationRules lt TData gt errors ErrorMessages lt TData gt return function validate data TData ValidationResult lt TData gt const result ValidationResult lt TData gt valid true errors Object keys rules forEach key gt Find a validation rule for each field const field key as keyof TData const validate rules field If no rule skip this field if validate return If the value is invalid show an error if validate data result valid false result errors field errors field return result This function takes rules and errors as input and returns a validator function This validator will take data check each field with a matching rule and record an error if the value fails Functions that take other functions as input or return other functions are called higher order functions This is one of the main abstraction control methods in functional programming We can use such a factory like this validation tsexport const validateForm createValidator rules errors The validateForm signature will be ApplicationForm gt ValidationResult lt ApplicationForm gt Thanks to the generics the function understands which data structure it is going to work with The validator itself we can use like this main ts …const data ApplicationForm Object fromEntries new FormData e target const valid errors validateForm data If valid show errors to the user … Patterns Pattern matching and MetaprogrammingSome may have seen this approach as a distorted “Strategy pattern and some as “not very good and not well defined pattern matching On the whole you re right The rule oriented declarative approach can be thought of as an abstraction management tool It s like we re writing programs that can generate a large number of other more specific but working by almost identical rules The advantage is that with less effort we can generate a lot of “almost identical code without duplication And while we are on the subject of advantages let s evaluate the rule based approach to validation in general Advantages of Rule Based ApproachI could count five of them ExtensibilityAdding new rules or changing existing rules becomes easier At the very least it s always clear where to look for the place to update For example if we need to add a new criterion for a password say to contain a wildcard then we add a new feature const hasSpecialCharacter password gt contains password specialCharactersRegex And then add it to the list of rules for password verification const passwordRules hasRequiredSize hasCapital hasDigit hasSpecialCharacter If we need to update a function say replace the mail check with a regular expression check we will only update the validateEmail function const validateEmail email gt emailRegex test email If we need to add a new field to the form then we update the list of rules and errors Suppose we want to add a field with the size of the clothes in order to sew the form correctly const validateSize size gt The validation rule const rules All the other rules size validateSize const errors All the other error messages size Please use American size chart And if you want to remove the field from the form you just need to find and delete the code associated with it ReadabilityThe declarative style is easier to read than the imperative style When writing declaratively it is easier to spot different levels of abstraction and explain your intent in terms of the subject area This allows you to avoid wasting resources on “parsing unnecessary details in your head later when reading the code TestabilityPure functions are easier to test You don t need to “mock services and “configure the infrastructure“for them a test runner and test data are enough Each rule can be tested in isolation or if there are many of them you can run the tests in parallel The validation service itself can be checked once If we made sure that it composes the functions correctly and runs the value through all the rules we won t need to check it every time Live DocumentationRules described by functions with clear names can be given to “non programmers to check Not always of course but ideally you can Such rules can be made part of the ubiquitous language from Domain Driven Design Scott Wlaschin has written extensively about ubiquitous language in Domain Modeling Made Functional Great book totally recommend it No DependenciesYou don t need any third party libraries for this kind of validation This may not work for some people for various reasonsーthis is more of an advantage for me specifically I generally try to choose dependencies carefully If some piece of functionality I can write myself and it won t be a buggy bike and a black hole in terms of resources and time then I ll consider the “write it myself option If you really need the library then the pure functions won t be difficult to pair with it Especially if the library also supports the declarative approach like React Hook Form In general any approach that s based on lightweight function type abstractions is relatively cheap to combine with libraries and third party services Rule based validation is just one such approach DisadvantagesWe cannot do without disadvantages here Here s what I have encountered while using such validators Need Contract for Error HandlingIt s not always clear what we should return as a result of validation In the example we return error messages for each rule but maybe we need to report errors for each criterion or the first character where the error occurred or something else This requirement may change from project to project You could put the contract definition in a separate function or write a more general validator but then the code could become too complex It helps me to keep the infrastructure logicーfactories composers runnersーseparate from the rules In that case replacing or extending the error contract is easier Performance and ConvertersThere are two rules in the example code that smell a bit validateBirthDate and validateExperience Their criterion functions convert strings to dates and numbers and do so every time they are called Date parse called twice when just one field is checked const validDate birthDate gt Number isNaN Date parse birthDate const allowedAge birthDate gt inRange yearsOf Date parse birthDate MIN AGE MAX AGE Complex structures can lead to performance degradation Ideally conversion should be done once And it would be nice to cover the structure with types before and after conversion We could use the type function type BirthDate TimeStamp type ExperienceYears YearsNumber type ApplicantForm birthDate BirthDate experience ExperienceYears function toApplicantForm raw RawApplicantForm ApplicantForm return raw birthDate Date parse raw birthDate experience Number experience Validator as Unwanted DependencyIf you get distracted you can accidentally drag the validation service as a dependency into all the other modules I try to make sure the domain logic is clean and not dependent on third party services It usually helps to split the value check and its retrieval from the object In the example of mail validation it would be like this Domain function works with a domain primitive const isValidEmail email EmailAddress gt email includes amp amp email includes Function in the application layer works with the whole form object const validateEmail email ApplicationForm gt isValidEmail email Then the business rules would be even cleaner and more independent but most often it s an overhead Sometimes you can sacrifice “cleanliness for brevity Inconvenient DTO Validation when Deserializing in Domain ObjectsIn general this disadvantage follows from the previous one If we don t isolate domain functions all the way to the end the rules are hard to use when deserializing data transfer objects I recommend reading more about DTOs their serialization deserialization and when to validate data when creating domain objects in Domain Modeling Made Functional by Scott Wlaschin Also you ll have to think about how to handle errors But we ll talk about error handling some other time SourcesAs usual I ve put together a huge list of sources and references for the text of this post Enjoy Application and Source CodeMars Colonizer Application FormSources on GitHub Common Computer Science TermsCompositionBinary LogicPrimitive ObsessionCouplingCohesionLaw of Demeter Declarative Approach and Functional ProgrammingPure FunctionsFunction CompositionPredicate FunctionsHigher Order Functions Pattern MatchingDeclarative Programming Software Design and ArchitectureDomain Driven DesignData Transfer ObjectShared kernelStrategy Patter“Domain Modeling Made Functional Scott WlaschinClean Architecture on FrontendDDD Hexagonal Onion Clean CQRS …How I put it all togetherGenerics in TypeScriptTypeScript Handbook Abstraction and Levels of ComplexityAbstraction LayerSeparation of ConcernsClimbing the infinite ladder of abstractionPrimitive Obsession Books About This Topic“Structure and Interpretation of Computer Programs by H Abelson G J Sussman J Sussman“Domain Modeling Made Functional Scott Wlaschin More from My BlogClean Architecture on FrontendLet s Write a Binary Adder in the Game of Life Generating Trees Images on Canvas Using L Systems TypeScript and OOP 2022-02-15 10:49:50
海外TECH DEV Community From papar to publish : My journey from 💡idea to publishing app on play store. https://dev.to/marianvelani/from-papar-to-publish-my-journey-from-idea-to-publishing-app-on-play-store-95c From papar to publish My journey from idea to publishing app on play store experience the app here As an electronics engineer I am always curious about android development so I learned Android development using java Now I want to build an app that provides some real value to their user In short I want to publish my app to the play store from where users can download and use it Why android • million user Android users•Open source•High success ratio•Large communityI build lots of apps for practising Android development but I want app ideas that must provide some value to their user we have lots of categories in android to develop apps on it so I prefer to observe the world for selecting a category from it after someday I get the idea to build an app for it I prefer to select art amp design categories for my app and The app idea is to provide references and new designs to mehndi design artists Mehndi is a form of body art and temporary skin decoration from the Indian Subcontinent usually drawn on hands or legs Idea •Provide a new mehndi design •Mehndi design course with certificate of completion Now according to the idea or need we have to provide an application based solution first of all every application idea has there own function requirements for functionality I meet some mehndi design artists to get content and design guide from it from there I get mehndi designs and structured basic mehndi design course Now I have content now I can start building an app and I start programming an app after understanding the requirements Requirements and solutions Design is in the form of the image so the app must support image view Design image must be zoomable For providing and updating the new Mehndi design real time database and Cloud storage required  Firebase For sorting and search every design must have a unique id DesignedShare button for sharing image URL to social media which support deep link for communicating app to app For future reference design must be saved or has the favourite section to pin it so we use SQLite to solve this The course of mehndi design is in form of a video so we need a video player I integrated youtube as a video player Certificate generation certificates are generated as images on the user side by using canvas and bitmap in the program  Tracking the progress of users we used SQLite Many more I preferred starting an app development from designing UI Ui •Must be simple and straight •Don t confuse users for better design Starting UI design on paper is time saving and flexible for ideation and brainstorming UI Design idea to implement Home layout Category layout Fullscreen Layout Favourite layout Course Layout Video Layout Certification layout After programming the backend the app is now ready to publish on the play store and I published it You can experience the app here 2022-02-15 10:11:19
海外TECH DEV Community How to Write Clean C# code? 5 Tips that will save you hours of programming https://dev.to/dotnetsafer/how-to-write-clean-c-code-5-tips-that-will-save-you-hours-of-programming-d36 How to Write Clean C code Tips that will save you hours of programmingProgramming isn t always as simple as it seems sometimes it requires you to write code that might not be quite as straightforward or easy to use as you d like You might also need to edit other people s messy code from time to time if you work in a company where developers aren t the cleanest coders around and that can prove to be rather problematic and annoying especially if you don t know how to do it properly yourself As you already know    and for those who don t know   I m creating a series of articles exclusively for Writing Clean C Code So let s go see new ways to save headaches Limiting function argumentsIt is very important to limit the number of parameters that a function has Remember The simpler the better The problem comes when a function has more than arguments because it can cause many problems in understanding what it does Bad way public void ProtectApplication string path string configurationPath string outPutPath CancellationToken cancellationToken Good way public class ProtectionConfig public string Path get set public string ConfigurationPath get set public string OutPutPath get set public CancellationToken cancellationToken get set var config new ProtectionConfig Path app exe ConfigurationPath shield config json OutPutPath app protected exe CancellationToken source Token public void ProtectApplication ProtectionConfig config The best option is to use or arguments Can you use more Of course you can but only if you are aware that in a couple of months you will have to figure out what is supposed to do what The ideal would be to group when there are or more If you have more than arguments in your function it means that function is doing too many things Name the functions with what they doAnother bad practice is to name functions with incorrect or incomplete names Just by reading the name of the function we should know almost of what EXACTLY it does otherwise this only causes confusion Bad way public class SlackNotification public void Handle SendMessage this to this files this body var message new SlackNotification What is this A handle for the message Are we writing to a file now message Handle Good way public class SlackNotification public void Send SendMessage this to this files this body var message new SlackNotification Clear and obviousmessage Send The best recommendation is to spend a little more time thinking of a name that is very descriptive for the function If you don t do this good practice   just to save a couple of seconds in defining a good name you will waste a lot more time in the future reading those lines of code and trying to understand what they do Never save unused codeThis bad practice reminds me of when we keep or collect stuff at home but never make use of it This is the same if you have code that is not used delete it There is no point in having it taking up space and bothering you Bad way public void OldRequestMethod string url public void NewRequestMethod string url var request NewRequestMethod requestUrl SlackChannel dotnetsafer request get users Good way public void RequestMethod string url var request RequestMethod requestUrl SlackChannel dotnetsafer request get users Remember Don t bite off more than you can chew If you haven t used that code there s no point in keeping it there You can still check it again in the version history in case you ever need it One level of abstraction per functionIf you are developing and you find that a function does not have only one level of abstraction but has several this means that the function is doing too many things by itself This bad practice apart from in the future generating questions like What is this What exactly does it do It makes it difficult to reuse code because it does many things at the same time Bad way public string ParseBetterJSAlternative string code var regexes var statements explode code var tokens new string foreach var regex in regexes foreach var statement in statements var ast new string foreach var token in tokens lex foreach var node in ast parse Good way class Tokenizer public string Tokenize string code var regexes new string var statements explode code var tokens new string foreach var regex in regexes foreach var statement in statements tokens return tokens class Lexer public string Lexify string tokens var ast new foreach var token in tokens ast return ast class BetterJSAlternative private string tokenizer private string lexer public BetterJSAlternative Tokenizer tokenizer Lexer lexer tokenizer tokenizer lexer lexer public string Parse string code var tokens tokenizer Tokenize code var ast lexer Lexify tokens foreach var node in ast parse This apart from leaving the code cleaner will allow you to reuse code and test it which you could not do properly before due to the large amount of things the function does Never write in global functionsThis bad practice consists of contaminating the globals This is not a good thing because you could have problems and even crash with another library Any user could run into this problem and would not realize it until the exception occurred Bad way public Dictionary lt string string gt Config return new Dictionary lt string string gt product shield Good way class Configuration private Dictionary lt string string gt configuration public Configuration Dictionary lt string string gt configuration configuration configuration public string Get string key return configuration ContainsKey key configuration key null After this we load the configuration and when it is ready we create an instance of the Configuration class var configuration new Configuration new Dictionary lt string string gt product shield Now yes in the application we should use one instance of ConfigurationThese ways are a bit more advanced than the ones in the previous article but they are still simple   but very useful As I said the number of ways to write cleaner code in C is more infinite than the universe That s why I m creating a list of Cleaner C Code and yes I recommend you check it out In case you missed the previous tips Important Tips to Writing Clean C  Code Dotnetsafer・Feb ・ min read csharp dotnet productivity beginners If you are interested don t forget to follow us so you don t miss any news 2022-02-15 10:03:29
医療系 医療介護 CBnews 国保連12月審査分、件数・医療費ともプラス-患者数はコロナ前に戻らないまま https://www.cbnews.jp/news/entry/20220215185701 国民健康保険 2022-02-15 19:10:00
金融 RSS FILE - 日本証券業協会 個人情報の苦情処理に関する実績報告 https://www.jsda.or.jp/shiryoshitsu/toukei/kojn_kujyou.html 個人情報 2022-02-15 10:19:00
金融 金融庁ホームページ 入札公告等を更新しました。 https://www.fsa.go.jp/choutatu/choutatu_j/nyusatu_menu.html 公告 2022-02-15 11:00:00
ニュース BBC News - Home Russia pulls some troops back to base https://www.bbc.co.uk/news/world-europe-60386141?at_medium=RSS&at_campaign=KARANGA russia 2022-02-15 10:40:54
ニュース BBC News - Home UK wage growth lags rising cost of living https://www.bbc.co.uk/news/business-60373405?at_medium=RSS&at_campaign=KARANGA figures 2022-02-15 10:16:00
ニュース BBC News - Home England women to host South Africa and India in 2022 https://www.bbc.co.uk/sport/cricket/60373071?at_medium=RSS&at_campaign=KARANGA overs 2022-02-15 10:01:17
ニュース BBC News - Home What does Putin want? https://www.bbc.co.uk/news/world-europe-56720589?at_medium=RSS&at_campaign=KARANGA ukraine 2022-02-15 10:29:51
ビジネス 不景気.com ツバキ・ナカシマがオランダ工場閉鎖、ボスニアに集約 - 不景気.com https://www.fukeiki.com/2022/02/tsubaki-nakashima-pullout-netherlands.html 集約 2022-02-15 10:26:04
ビジネス 不景気.com エンガジェット日本版とTechCrunchJapanがサイト閉鎖へ - 不景気.com https://www.fukeiki.com/2022/02/engadget-techcrunch-cease.html japan 2022-02-15 10:01:51
北海道 北海道新聞 ベテラン岩崎、力強い41球 新天地の中日でフル回転目指す https://www.hokkaido-np.co.jp/article/646036/ 沖縄 2022-02-15 19:19:00
北海道 北海道新聞 国のスマホで副反応調査、低調 目標の1%にも達せず https://www.hokkaido-np.co.jp/article/646035/ 厚生労働省 2022-02-15 19:14:00
北海道 北海道新聞 美唄市2万人割れ 1月末 市制施行以来初めて https://www.hokkaido-np.co.jp/article/646028/ 住民基本台帳 2022-02-15 19:13:00
北海道 北海道新聞 氷のさい銭箱に多数の硬貨 もんべつ流氷まつり https://www.hokkaido-np.co.jp/article/645998/ 諫早 2022-02-15 19:12:53
北海道 北海道新聞 「コロナ収束を」氷の神社で祈る もんべつ流氷まつり 長崎の宮司訪問 https://www.hokkaido-np.co.jp/article/646000/ 開催 2022-02-15 19:12:23
北海道 北海道新聞 日ハム新庄監督、ファン沸かせる 巨人原監督に香水贈る https://www.hokkaido-np.co.jp/article/646027/ 沖縄セルラースタジアム那覇 2022-02-15 19:12:00
北海道 北海道新聞 道産ワインの課題議論 北大寄付講座が初のシンポ https://www.hokkaido-np.co.jp/article/646026/ 人材育成 2022-02-15 19:11:00
北海道 北海道新聞 北海道コカ・コーラ値上げ 大型ペットボトル、5月から5~8% https://www.hokkaido-np.co.jp/article/646001/ 北海道コカ 2022-02-15 19:10:47
北海道 北海道新聞 「シャッターアート」で町明るく 静内高生、活動資金募る https://www.hokkaido-np.co.jp/article/646024/ 新ひだか 2022-02-15 19:09:00
北海道 北海道新聞 まん延防止延長、道が政府に要請 https://www.hokkaido-np.co.jp/article/646021/ 新型コロナウイルス 2022-02-15 19:04:07
北海道 北海道新聞 日銀マイナス金利、導入から6年 預金急増、効果に疑問符 https://www.hokkaido-np.co.jp/article/646023/ 預金 2022-02-15 19:03:00
北海道 北海道新聞 大阪市のヘイト規制条例、合憲 表現の自由制限やむを得ず https://www.hokkaido-np.co.jp/article/646022/ 表現の自由 2022-02-15 19:01:00
IT 週刊アスキー 『BD ブリリアントライツ』に新キャラクター「アルテミア」(CV:西沢広香さん)が登場!ストーリー第5章も追加 https://weekly.ascii.jp/elem/000/004/083/4083580/ 西沢広香 2022-02-15 19:55:00
IT 週刊アスキー 画面表示の改善などを実施。サバイバルSRPG『屍喰らいの冒険メシ』のアップデートパッチが3月上旬に配信決定 https://weekly.ascii.jp/elem/000/004/083/4083578/ nintendo 2022-02-15 19:50:00
IT 週刊アスキー プレモルの最高峰「マスターズドリーム」の「無濾過」が全国販売へ 気になる味は? https://weekly.ascii.jp/elem/000/004/083/4083585/ 醸造家 2022-02-15 19:45:00
IT 週刊アスキー 育ての親の教えを胸に……!PS5/PS4『Horizon Forbidden West』の最新映像「シネマティックトレーラー」が公開 https://weekly.ascii.jp/elem/000/004/083/4083573/ horizonforbiddenwest 2022-02-15 19:20:00
IT 週刊アスキー JAPANNEXT、USB Type-C 65W給電対応の28型4K液晶ディスプレー「JN-I28UR-C65W」発売 https://weekly.ascii.jp/elem/000/004/083/4083561/ amazoncojp 2022-02-15 19:15:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)