best-practices | Documents best practices for software development
kandi X-RAY | best-practices Summary
kandi X-RAY | best-practices Summary
This repository has largely been superseded by the USGS Software Management Website.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Parse certificate file .
best-practices Key Features
best-practices Examples and Code Snippets
Community Discussions
Trending Discussions on best-practices
QUESTION
I know that according to Cypress Best Practices it's recommended to not test 3rd party apps which are not under one's control, but as a a future tester, I'm asserting my authority by doing so anyway!
So I just wanted to test the log in
procedure and POST
response with status 200
for this particular page, so I wrote the following test case here:
ANSWER
Answered 2022-Apr-16 at 23:20Below
Here comes the human tester that kills the reCaptcha manually IF NEEDED
insert the following:
QUESTION
According to this fabulous article by Thorben Janssen a bidirectional association for @OneToMany works like this:
...ANSWER
Answered 2022-Apr-05 at 13:35To understand what's going on you need to be familiar with Hibernate ORM entity states.
In your case, both entities are managed and therefore Hibernate ORM knows that it needs to apply the changes. item3
is managed because it has been persisted, order
is managed because it's the result of a find
.
The javadoc for session.save
starts with:
Persist the given transient instance ...
None of the entities are transient in this case.
Note that you would be able to change the example, depending on how you map the association with different cascade types.
For example, if the association items
is mapped using CascadeType.PERSIST
, this would also work:
QUESTION
Using React Navigation 6, in the documentation, they recommend you use Groups to minimize nested navigators.
However I'm not sure how to do that in this example, using a nested Stack in a Tab Navigator:
...ANSWER
Answered 2022-Mar-29 at 09:32The problem here is that Group
is a component returned by the navigator
. If we create a JSX component that returns that group instead, then this is technically not a Group
anymore but its own JSX component.
This is an unsolved problem in react-native-navigation
and is discussed in this GitHub issue, but has apparently no satisfying solution other than an ugly hack.
We can call the functional component inline.
QUESTION
I am learning the Google Cloud platform, trying to implement my first project and am getting lost in the tutorials. I am stuck at the trying to implement an nginx ingress. My ingress is stuck in CrashLoopBackoff and the logs show the following error.
I know how to do this task with DockerCompose, but not here.
Where do I start?
...ANSWER
Answered 2022-Feb-23 at 04:12Instead of using that and following setup of GCP CA setup i would suggest using cert-manager with the ingress.
Cert-manager will get the TLS cert from let's-encrypt CA , cert-manager will create the secret into k8s and store verified certificate into a secret.
You can attach secret with the ingress, as per host and use it.
YAML example :
QUESTION
I have read these articles:
ASP.NET Core Performance Best Practices
When should I use Task.Run in Asp.Net Core?
Is it allowed to use Task.Run in an ASP.NET Core controller?
In the first article in docs.microsoft
we can see this statement:
Call data access, I/O, and long-running operations APIs asynchronously if an asynchronous API is available. Do not use Task.Run to make a synchronous API asynchronous.
I don't understand this statement well. I'm confused about where and when I should use Task.Run
and where and when I should (can) write async web API. For example, consider this method:
ANSWER
Answered 2022-Feb-03 at 04:44I'm confused about where and when I should use Task.Run
On ASP.NET, almost never. You can adopt "never" as a general rule.
and where and when I should (can) write async web API.
Your controller actions should be asynchronous if and only if they invoke asynchronous code. Generally speaking, you should prefer asynchronous APIs at the lowest level for all code that performs I/O. Then your action methods are asynchronous only if they need to call that asynchronous code.
I should write a web method synchronously because there is no async version ... but for method 2 I can change it this way
Yup.
Is there any way to run the first API async?
Think of it this way: if there is synchronous (CPU-bound) work to do, then that work needs a thread. It's already running on a thread pool thread (because web requests run on threads from thread
pool). Task.Run
will move that work to a different thread pool thread, but it will still run on a thread pool thread. So Task.Run
doesn't help anything; it just adds overhead and provides no benefit. Hence the general rule of "don't use Task.Run
on ASP.NET".
QUESTION
I was reading about the .gitattributes
file and the rule to force line endings in some tutorials it's written like * text=auto
and in some others, it's like * text=auto eol=lf
at the first line of the file.
Are there any differences? what does the first one exactly do? Does it even force any line endings?
Also in some repositories it's mentioned that * text=auto
preforms LF normalization! I don't know whether it's true or not.
ANSWER
Answered 2022-Jan-10 at 23:27There's a difference between these attributes. text
asks Git to perform line ending conversion. Any time Git does this, it will store LF endings in the repository, and it will convert them when it checks files out in the working tree. text=auto
asks Git to search the beginning of the file for a NUL byte, and if it finds one, then the file is binary and conversions are not performed; otherwise, the file is text, and conversions are performed. This usually works fine in most cases, and is a sensible default.
By default, Git honors several configuration variables to decide what line ending conversion should be used in the working tree (LF or CRLF), unless the eol
attribute is set. If eol
is set, then (a) the file is automatically set to be text
and (b) that line ending is always used.
So in the former case, * text=auto
says, "Guess whether this is a text file, and if it is, check this file out with the user's preferred line endings." The eol=lf
applies only to files that are guessed as text
in this case, as of Git 2.10. In general, eol
applies if text
is set explicitly, text=auto
is set and the file is detected as text, or if text
is left unspecified; in Git 2.10 and newer, it doesn't affect files explicitly marked -text
or detected as binary with text=auto
.
However, if you're using older versions of Git, this can cause some binary files to be mishandled, since it will force them to always be text. If your repository contains only text files, then it will work, but this is better written as * text eol=lf
. Otherwise, you can specify different types of files separately:
QUESTION
I've read and re-read https://docs.microsoft.com/en-us/dotnet/csharp/how-to/compare-strings and https://docs.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings and I am still unclear on one thing: what comparison type should I use for user inputted strings.
IE, let's say I have the string in a db record that supports unicode, and before running an update query on the database, I want to make sure the string has actually changed so I do if (string.Equals(dbstring, userinput, StringComparison.?)) { // update db. }
So which one do I use? Reading the guides above, I primarily use StringComparison.CurrentCulture for UI display such as sorting, and I use Ordinal most things under the hood, and I should rarely use InvariantCulture.
The part that is confusing me is this line (emphasis mine):
Do not use string operations based on StringComparison.InvariantCulture in most cases. One of the few exceptions is when you are persisting linguistically meaningful but culturally agnostic data.
What do they mean 'persisting'? Does this apply to the case of storing unicode strings of user input in a database?
...ANSWER
Answered 2021-Dec-06 at 21:31"Persisting" in most cases means "storing". Just that. Fancy word for simple thing.
It doesn't really matter if it's database storage, file storage, internet cloud storage, or, yes, even in-memory storage -- even though "in-memory" doesn't usually coincide with thinking about storage, since it tends to evaporate when the power goes out. It's more about how you are going to use this data, rather than where you are going to store it. So even building a in-memory most-recently-used list of terms can be thought as "persisting", if it's kept long enough in a typical non-disastrous case.
So, yes, storing unicode strings in a database is exactly as good use case for the word "persisting" as it can be.
--
However, for your use-case of determining whever the text entered by the user has changed, I'm not sure if you should focus on the 'persisting' aspect. At this point I think you don't really care about storing, you care about "has it been changed", and that should determine the choice of string comparison.
All StringComparison flags have some effects. Culture vs Invariant, Case-Sensitive or not, how would you like the comparison to behave, so that the result will be clear and understandable to the user?
If old text was "Mary has a lamb" and new text is "mAry HaS a Lamb", should it be treated as a change?
If old text was "Maria hat ein weißes Lamm" and new text is "Maria hat ein weisses Lamm", should it be treated as a change?
and so on. Right now I can't think of better examples, I'm sure you could think of some when focusing on your userbase and on what will be of the most use to them.
Please note, that they also may not care, and that you may be overthinking it or focusing on too tiny details too soon. Maybe the default comparison would be just fine for first few years until users tell you it could be better here and there? Dunno. YMMV :)
QUESTION
According 8th step of this post I wrote following simple unit test to sure my Test
class doesn't cause memory leak:
ANSWER
Answered 2021-Nov-16 at 06:03There are very few possibilities where this test would do something useful. All of them would involve that the constructor of Test
does some kind of registration on a global variable (either register itself on a global event or store the this
pointer in a static member). Since that is something that's very rarely done, doing the above test for all classes is overshooting. Also, the test does not cover the far more typical cases for a memory leak in C#: Building up a data structure (e.g. a List) and never clean it up.
This test may fail for a number of reasons: GC.Collect()
does not necessarily force all garbage to be cleaned. It should, but there's no guarantee that it will always happen. Also, since testObj
is a local variable, it is not yet out of scope when you call GC.Collect()
, so depending on how the code is optimized, the variable cannot be considered garbage yet, which makes the test fail.
QUESTION
According to Google, all new Google Play apps from August 2021 would need to target API 30, besides being derived as Android App Bundles. Furthermore, from November 2021, even app updates would need to conform.
So I was updating my app from targeting API 29 to API 30, and some functions broke. How do I figure out the reason(s)? From the list of changes given by Google, it is not obvious, as it is not just a matter of checking whether certain deprecated APIs are being used.
Ideally, if Android Studio might provide a way to see how features in API 30 affect my app behavior, that would be cool.
...ANSWER
Answered 2021-Oct-28 at 17:25I discovered a cool feature in Android Developer options, called App Compatibility Changes. Google describes these Compatibility Framework Tools in this way:
Android 11 introduced new developer tools for testing and debugging your app against the behavior changes in newer versions of the Android platform. These tools are part of a compatibility framework that lets app developers turn breaking changes on and off individually using developer options or ADB. Use this flexibility as you prepare to target the latest stable API version and as you test your app with the preview release of the next Android version.
Wow, and looking at it on the phone, it appears you can actually toggle each new feature/change on or off individually?
Well, let's see; first it gives us a list of all the debuggable apps on the device, and if we select one of them, say, targeting API 29, then we can actually toggle on/off each API 30 feature individually, as shown in the example below, with CALLBACK_ON_CLEAR_CHANGE.
Cool! Just two points to note: this works with debuggable apps only; and if you're wanting to turn on/off features of API 30, build your debuggable app targeting the API level below it, i.e., API 29 in this case, and then turn on/off features and test away! If you've no idea which feature is causing the problem(s), you can speed up the search by selecting, say, half of the 30 or so changes, see if the problem(s) are there or not, and so on, to zoom in to the right toggles.
QUESTION
I'm currently working with a team developing a bunch of web components, supposed to be the basis for a current and also upcoming web applications developed in the customer's company.
I want these components to support color themeing; the first use-case for this being supporting a dark mode.
Current approachI have defined the customer's corporate design colors in a file
...colorpalette.css
(the colors are just an example):
ANSWER
Answered 2021-Oct-20 at 03:32In my opinion, the priority requirement of a theme system is easily changing the appearance. So your first solution would be suitable for this case. Let's talk about its cons.
This approach obviously results in a myriad of variables, as we need to define a separate variable for each place where we need to apply a different color.
More variables are needed. Cause they serve different purposes. And when you re-design your theme, it will help you quickly change the appearance without traveling into all the components files. And you only need to care about it just in case re-design the theme. So I think it should not be counted as cons.
If you later want to introduce additional button variations, you'd have to edit both
colors.css
andbutton.css
.
Again, I don't consider this is cons because you just need to add some extra code in 2 files. And these codes will not affect anything that exists before.
But you forgot to mention the biggest con of this approach. It is you need to rewrite the CSS rules. What's happens if we use a gradient background? The code will be something like that:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install best-practices
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