This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Does readdir() guarantee an order?
I'm guessing this isn't the case, and I'd need to manually check the name of each entry instead of just skipping the first couple. Is that correct?
The POSIX standard does not guarantee anything about the order of directory entries whatsoever. As such, if you're interested in filtering out . and .., you do need to compare for them.
No, you should never rely on finding . and .. first (although it almost always happens).
I remember one case when I had problems with such an assuption (on ReiserFS they were not found first, but it was an old version of ReiserFS, now it may be different).
It is not in the standard, but I have never seen them in any other place, but the first two. But, just in case, if you don't realy mind the time that much, I would do the check.
Related
My Optaplanner version is 7.24.0
Can I set the thread number like bellows?
Construct Heuristics : single thread
Local Search: multi thread (for example 4)
Because, some data shows different result in construct heuristics.
I found that the data is affected by thread number.
(It shows always the same result every time in single thread.)
Best regards
It is not possible to use different move thread count in CH and LS. If you need that, you will have to run the solver twice - first just the CH, then just the LS.
That said, some comments:
What you're describing sounds like a bug. Either a bug in OptaPlanner, or a bug in your domain. Construction Heuristics is a deterministic algorithm.
Are you really using OptaPlanner 7.24? That release is, by now, nearly 4 years old. You are missing out on so many performance improvements and bugfixes, and I don't even remember anymore if the behavior you are describing was something we've seen or fixed since. I strongly recommend you upgrade to the latest version; you'll be surprised by how easy it is, and by how much you gain.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
it just so happens that my class is a (Medical)Service, do you have any suggestions on what I would name a Service in angular that retrieves medical services?
So far I have thought of two things:
MedicalServicesService sounds a bit weird or not?
I was thinking of maybe replacing "(medical) service" by a synonym, maybe "medical assistance". Then I would have MedicalAssistanceService as the (programming) service name.
Still, surgery hardly passes for a medical assistance. It really is a medical service.
Was curious what people do when one of their classes names just happens to use a programming keyword. A question open for debate.
Not sure if naming conventions questions are allowed here? I will gladly delete my question if they aren't. Thank you.
First off, this depends a lot of the language.
TALK TO YOUR TEAM
Secondly, and most important! Conventions may change a lot depending on your team. Talk to your team, and agree on one convention to use. Never forget this.
Conventions
There are universal conventions/standards to follow, and like you mentioned, using keywords is usually a bad-ish idea. I for one try to avoid them, just as I avoid using digits in my variable-names, even if the specific language I'm working with allows it. Reason? It's easier to stick with "let's avoid problems by mixing rules between languages" than having to check the rules each time.
I often spend 30 minutes thinking of the perfect variable name, so I am quite used to this kind of pondering.
Length
Excessively long variable names is bad, because it hinders flow reading, while excessively short variable names are also bad because it is hard to guess what word you want. You could call it srvc, sure, but who will know what that means in a month (unless you comment it, sure). Dropping the vowels in user-variables is quite common, actually, especially in low-level/old languages.
Specific case
As for this specific example, I wouldn't think of MedicalService as a keyword. First off, it's part of a longer name, like MedicalFile doesn't look like a file from the system at all, but rather a form with medical data on it.
I don't exactly know what this MedicalService does, but it seems like a generic (abstract, probably) class name for services that you can ask for at the counter of a hospital, so I'm assuming that.
GenericMedicalThingToDo is a funny way to avoid the keyword, but I wouldn't call it that. MedicalUseCase seems quite better, and gets to the point.
On the other hand, if this is just a string stating the use case for whatever it is the user has chosen (considering you mentioned Angular), I would just stick with userMedicalChoice (drop the PascalCase to camelCase).
If you need to use a word that is actually a keyword, which often happens, you might want to add a _ on the end or the beginning of it. This is not usually good for interfaces, as it's conventional to only use those internally/privately. Some conventions use double _ for private, and single _ to avoid dupes.
Last point:
Having keywords as part of a longer variable name is not a problem in any of the many programming languages I have sailed in, so just call it MedicalService, or GenericMedicalService if you're going to subclass it.
PS: Read up on some conventions of different languages, like PEP-8, and PEP-256 from Python, or Google's C++ conventions. While not specifically being valid for all languages, they do give you something pin-pointers to what is important.
I have been using os.walk() to traverse a bunch of subdirectories inside a directory dir. These subdirectories are numbered from 0001 to 0899. I assumed that os.walk(dir) traverses these subdirectories in numerical order, i.e., as they are shown in the finder (I am on Mac), and so far I have had no reason to believe that this is not true.
However, a few days ago I noticed something strange: os.walk() suddenly (?) traverses the folders non-numerically (but always in the same sequence, I think). I am fairly sure that this was not the case before - I would have noticed.
I am aware that I can use sorted(os.walk(dir)) to have the subdirectories processed numerically, but that does not answer my question. How is it possible that the behaviour of os.walk() changed? Could it have to do with upgrading Python in the meantime (which I don't think I did - can this be checked somehow)?
EDIT: it occurred to my that I updated from OS Sierra to OS Sierra High in the meantime. Maybe that is where the answer lies?
I will answer my own question: it turns out that it was the fact that I had moved dir and its complete contents to a different place on my disk, thus giving them different addresses, that caused the different sorting.
I used to use a program finddupe on Windows (XP) which checked for duplicate files and offered to replace by hardlinks.
This calculated a hash of the 1st 32K, only checking the balance on match. I have the source (for VC++6), but was wondering if there is a Linux/OSX equivalent before I try to port it, although I suspect it may be better to write a new program in a higher level language.
I've found fdupes to be helpful for me.
If you are looking to write your own quick script, I would suggest looping over files and using cmp as it allows you to easily stop comparison after the first mismatched byte.
There are many similar tools. See here
They may not be part of standard distribution.
I have used fslint before and found it to be sufficient for my needs.
I know it's strange, but it will helpful.
I found two ways:
UNIX timestamp, it can keep absolute increment unless the datetime of the system(linux) is not modified unexpectedly.
Maintain a value manually such as in file/sqlite/mysql. But it difficult to do this in my situation.
Is there some value or some method in linux os?
Sorry, I discussed this issue with my friend. They think it maybe a philosophical problem:)