|
But why would anyone ever do that anyway?
|
|
|
|
|
If someone was using a class from a 3rd party library they wouldn't know what private fields are used.
So if I name my private field "foo" that means another person's class that uses my library can't use the field "foo" - even a private field in their own derived class.
This is why i prefix my private members with underscore - to make it less likely this will happen.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Interesting.
With private fields it's no a problem at all.
The base field simply isn't accessible from the derived class.
The two fields are simply "BaseClass.someField" and "DerivedClass.someField".
Things get different when you make the base class field public.
class Program
{
static void Main(string[] args)
{
Console.WriteLine(new Derived().SomeValue);
Console.WriteLine(new Derived().BaseSomeValue);
}
}
public class Whatever
{
public string someValue;
}
public class Derived : Whatever
{
private string someValue;
public Derived()
{
base.someValue = "Base someValue.";
someValue = "Witch someValue?";
}
public string SomeValue => someValue;
public string BaseSomeValue => base.someValue;
} This prints "Witch someValue?" and "Base someValue.", pretty much as you'd expect.
Visual Studio only gives me a warning that someValue hides an inherited base member and that I should use the new keyword if hiding was intended.
Basically, both are treated as separate variables, and settings someValue will not set someValue in the base class, neither will setting base.someValue do anything for someValue.
Adding the new keyword gets rid of the warning, but doesn't seem to change anything.
To get back to your specific example, same thing.
new Derived().foo will point to the property, new Base().foo will point to the field (assuming you meant it to be public).
And you get a warning that foo hides an inherited member so you should add the new keyword.
All in all it's pretty confusing and best avoided
|
|
|
|
|
Yep, that's my preference too. my_web_app just seems easier to read than MyWebApp.
|
|
|
|
|
long ago i learned that naming conventions cannot be universal.
So what I've done is I've created a pattern.
I use camel case where appropriate, .NET casing where appropriate, "sql server casing" where appropriate, etc
The thing I try to do is make them such that they can be algorithmically transformed between the different styles.
And i've written code to do it (often in code generators and sql script generators etc)
It works, and it's consistent enough that at least to the human eye, it's not confusing.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
For project names, I go with proper titles. NotEvenPascalCase, I use my spacebar. Which a Cygwin-wielding co-worker of mine seriously dislikes as spaces are apparently impossible to process with bash scripts. Well, sucks for him, sucks for bash, my PSH-scripts work with that stuff just fine. I dare to say that I don't shy away from non-ASCII characters either. We're in Germany here (so non-ASCII characters are a thing), we don't outsource work to other sites. Meaning that I keep all my stuff in Uuncode and don't bother about keeping it ASCII which again brings the blood of some co-workers to boil. Especially those who learned their craft half a century ago and couldn't be bothered keeping up to the field during all those years.
|
|
|
|
|
Wow, that seems very impractical...
I've also never seen it before.
The person who is going to have to maintain this after you will curse you.
And if your co-workers can't work with it either you should probably change your style.
Programming is a team sport and you can't just make up your own rules.
Even for me (a Dutch neighbor) typing öüï etc. takes two extra key strokes, and I can't do a ß at all.
Just because you can doesn't mean you should.
So I can't say I disagree with your coworkers and I learned programming this decade
|
|
|
|
|
Define "impractical". I claim that sticking to lessons half a century old is impractical. In certain cases, such as insistence on building linked lists by hand and freeing them, again by hand, in a different module instead of relying on C++'s standard containers, there's objectively measurable impact on productivity as this stuff is possible to get wrong thus development time gets wasted on fixing a homegrown solution instead of using a standard one.
You're right thought that IF I outsourced my work to, let's say, you, things would get very impractical very quick. But you've ignored the part of my post where I said explicitly that the code stays in Germany.
The only kind of people to curse me when I quit the company (which isn't going to happen anytime soon), are the kind of people stuck in the 60s. Or 80s, as for me. The kind of people who love short method names (because proccusl is totally more readable than ProcessCustomerList), who love doing stuff by themselves that the compiler does better (see example above) and sure, the kind of people who still live in the DOS age. Those will hate me. I live in a place with heating, water and electricity, shunning manual labor to have firewood in winter and having to go to a literal outhouse to take a dump (which is very fun in winter, trust me, I grew up in Russia and there's enough rural areas). It's time to accept that computing has moved on as well. It's time for my co-workers (well, I don't really care that much about them, but same goes for my successor) to stop living in the stone age.
Edit: Excuse me, I forgot to mention another important part to that discussion. German (or Dutch) umlauts aren't the only use for Unicode. Even if I was typing all my names in pure English, that wouldn't help with physical units. You see, you can stylize volume units as m^3 which is even somewhat wide'ish recognized, a m³ is way simpler and easier to understand. That ³, in case you wonder, isn't part of ASCII so it's either ANSI code pages (please don't get me started on this nightmare) or a Unicode literal. Well, git can deal with Unicode just fine, it doesn't know how to output it on it's CLI returning raw bytes but it can tuck away and retrieve UTF8 code files just fine. Of course I could refer this to some internationalizing framework (which I have and which again runs in Unicode), but m³ is the same all over the world, introducing a layer of indirection there is pointless. It should go without saying of course that the IDE and it's compiler understand UTF8 just fine as well. In fact, it was the IDE that I used to convert the whole solution to UTF8.
-- modified 13-Aug-19 4:28am.
|
|
|
|
|
Member 9167057 wrote: such as insistence on building linked lists by hand and freeing them, again by hand That's just madness, unless you're studying linked lists.
Member 9167057 wrote: the code stays in Germany "That will never happen" - Some guy before it happened
It's the biggest lie we keep telling ourselves and a lie that has cost many a company a lot of time, effort and money.
You'll get a foreigner in the team, you decide to leave the company, you land in the hospital and someone needs to take over, management decides a team in India is cheaper... All stuff that could happen tomorrow (let's hope that hospital equipment won't crash because someone used non-ASCII characters ).
I'm thinking about tooling that can't process your project names.
They may be tools from the 80's, who knows, but you'll still have to work with them.
There's a difference between using proccusl (which is also just madness in this day and age) and using PröceßCüstømerLîst, at least the first can be processed by every human and program everywhere.
I think all of us here have stories about applications that crashed because a file wasn't ASCII or UTF-8 or even BOM or whatever.
The spaces are pretty annoying as well.
I once used spaces in a project name, but quickly switched back once I had to use double quotes in practically every program I used with that application (like Azure DevOps, CLI tools, etc.).
The real fun was in using it within another double quoted string, which forced me to use escaped double quoted strings, like cmd = "dotnet build "My project""... Ehhh...
I can only imagine the pain if that project name includes weird symbols as well, even if YOU can type them.
Anyway, if you dislike your team so much because they're stuck in the 70's and 80's then why don't you find another job?
I know plenty of places that aren't stuck in the past, but would make very short work of your naming conventions
|
|
|
|
|
Ok, I promise you to replace all umlauts with either their transcriptions (ü->ue) or all names with English when the code goes abroad. Since I'm not high at work, that's something I a) will know and b) will remember when the time comes. That said, I don't see it happening anytime soon. I won't get a foreigner to work on my team because my company doesn't grasp for foreigners because they're cheaper, my company goes for qualifications and, very important in R&D, the will to stay with the company and the product for a while. Unless it's a menial code monkey job, it takes ~2 years to grasp the concepts and become a productive member. You don't outsource to the cheapest for something that takes 2 years to fully get into. I claim that going for the cheapest is the stupidest idea there is anyway. Still, I promise you that I'll English'fy my code should the need arise.
With that out of the way, let's get to the other topics. Tooling that works with the project is a base requirement for, well, anything and it hurts me that you assume I see it differently. The thing is, my tools work with my projects just fine. Obviously, the IDE & compiler work. I said earlier that git works with that stuff as well (save for displaying bugs on the CLI I don't care about). What else is there… The file manager obviously works fine, console as well. I hardly do anything interactive in the console anyway, I write scripts to do repeating tasks and the scripts work. Quoting quotes in PowerShell is darn simple, at least as long as only 2 levels of quoting are involved. That, and I wouldn't hard-code "My project", it looks similar to "dotnet build %ProjectNameComingFromADefineOrMacroOrParameter" in my scripts. Hard-coding such stuff is a bad idea, with spaces or without. The moment you rename your project, you may have to adjust the name in several places.
As for crashes in your applications, code!=data. Data files, the ones that go out into the world (or return from the world), are a peculiar topic, one very different from what we're talking here. I mean, sure, it's an interesting topic, but I feel that you're including it here to remain right, not because it adds to the discussion at hand. But I have an anecdote myself about how not using Unicode causes odd issues. You may remember physical units from my previous post. Well, a ³ in a West-European code page (or Central European, I don't remember) looks rather differently from some East Asian codepage where my product is also run. That incident was in fact the trigger for me to work in Unicode.
As for other tools, I strongly disagree. If a tool is from the 90s, chances are, it's simply bad (i.e. security issues which no-one cared about in the 90s), incompatible with any modern environment or there's a better successor anyway. My point is, I've yet to see a tool which I need for which there's no replacement and which doesn't support Unicode. Or spaces, for that matter. Ok, git doesn't really, but it doesn't crash and doesn't corrupt anything either, so I'll go with "git just works".
As for customer-facing data, my 2 favorite exchange formats are Excel (for customer convenience) and ASCII text files with plain English for internal'ish stuff. I'd like to use XML for better structure, but it would be overkill for the data I'm packing.
The reason for me to stay is several. First, the issues I named, namely grown-ups stuck in the past, I don't really care about. It makes for a nice anecdote every now and then, but I don't work with them directly. They use my code sometimes, I never touch theirs. We're sub-teams. Or teams within a group. Second, the place is actually great to work at. Good flexible hours, good pay, cool colleagues to hang out with after hours (not the ones I was talking about earlier) and the company likes it's employees to stay for a while (beneficial for R&D, beneficial for sales) because, as I was saying, going for the cheapest option available is plain dumb, as a couple articles on TheDailyWTF can confirm. And I love doing what I'm doing. Including staying up-to-date with development of tools I'm using. I imagine wishing to hang myself when trying to do that in the web space but on desktop, the couple articles I read about news in C++, C# and Delphi are palpable, not too many, almost always substantial and holy hell do I look forward to C++'s modules (which sure as hell will piss off the past-stuck people).
Now that talk about outsourcing and code monkeys reminds me... Going for the cheapest for a pure code monkey job is of course a viable alternative. Not that code monkeys make sense in the first place, a couple of people knowing what they're doing produce better code, than a horde of code monkeys, but some of the co-workers stuck in the past used to degrade me to a code monkey when we were working closer together. Maybe there's a causal connection here which I don't see.
|
|
|
|
|
|
I think we can agree then that I'm lucky working at a company where the boss floor isn't occupied by morons. That, and I'm lucky to work with mature tools in a mature ecosystem. That said, my condolences. At least I hope they're well-placed, every time I hear someone doing web dev, I think of http://www.commitstrip.com/en/2015/09/16/how-to-choose-the-right-javascript-framework/
|
|
|
|
|
That's how it is
Luckily, I don't do all that much front-end work... Which makes those times I do it even harder
|
|
|
|
|
Now I see your problem with my non-English characters. Correct me if I'm wrong please. As far as I know, having your methods (on the server) called from clients all over the world isn't exactly uncommon making worldwide-compatible naming a hard requirement while in my case, it literally couldn't matter less as my customers get a compiled binary which, save for some places I've used RTTI, doesn't contain any names at all.
|
|
|
|
|
|
While the comic is great, I can imagine having the pretty much same problems. Windows is an interesting example of itself, it's desktop-only (let's stick with client Windows), but Microsoft has a plethora of compatibility shims because desktop apps written for version X rely on quirks of version X and break when facing version X+1.
The usual solution is to cleanly define the interface and simply not break it. The implementation can change, but who cares? Speaking from experience here, an externally-usable DLL is a part of my main product and I've changed it's guts several times in my time here, including one complete rewrite. Nobody cares because the outside stays the same.
Isn't it the same in the server space? Publish an API, publish a documentation and simply don't break the API thus having all clients using it by the book not breaking? I don't have that much experience there, what's preventing web APIs from staying stable once published?
|
|
|
|
|
Yeah, that's basically how it goes.
It's a bit difficult for SOAP, for example, because you can't just add new properties to your API (which is sometimes necessary).
You must make sure they can be omitted, for example by making them nullable.
It's easier for REST, which doesn't check the incoming message and just makes the best out of it (which also has its drawbacks).
I always say, the best versioning is no versioning at all.
Just make sure you don't break the API.
But that assumes your API is perfect from the get-go, which it rarely is.
My last big rework, for example, had an API which got a complete object from the client and then created object x and object y and added some of object z.
Then came some functionality where we just had to add object z and also object y was no longer necessary...
The best solution was really to break that complete API and rework all clients (which, luckily, was only one)
I think the biggest problem, in comparison with (strongly-typed) desktop development, is that your API definition can change without the client side breaking.
You just send message back and forth and try to make something of it at runtime.
That's (sometimes) better with SOAP, but also not always (and I like REST better anyway).
So even if you're very careful, but still make a mistake, you won't find out until you test that particular service call (which isn't a simple unit test) or until it breaks in production
I've had the same problems with some late-bound desktop development, but usually you target a specific version of a DLL, so the API is known at design time and your build simply fails.
|
|
|
|
|
Let's see:
You can call it foo or bar or fubar
You can call me Ray or you can call me Day, or you can call me RayDay.
You could put a number on the end.
You could use an online theosaurus and find something that measn what you really want to call it.
You could get one of those books of baby-names, boys names, girls names, etc, and just use the next name out of that. It works for hurricanes.
|
|
|
|
|
Sander Rossel wrote: this kind of stuff bothers me more than it should
If it helps try and think of it like difference between how people are named in different parts of world. Like in the western countries there's usually a given name, followed by middle name (one of either mother or father) followed by family name. In Arabic countries it is common to find only one given name for the individual followed by an iterative ibn (meaning son of) or bint (daughter of) of all their ancestors. In south Asia there are usually two names, one given and one father's, occasionally you'd find a sect name before or after the two names. Or in some rare/unique cases as in mine you'd find three names with no relation to ancestors or sects. Just plain old names (all like first) brought together to create an ambigous meaning and make everyone in the family happy.
P.S. my name translates to An Ancient Enlightened Lion. "Ancient" is the only word I can think of but the name translates to something that has been around before time.
P.P.S. that rant was more for me than you, but you could still chose to see these differences and learn not to give a sh*t.
|
|
|
|
|
It's not really the same though.
I get that JavaScript has a different naming convention than .NET, and I gladly stick to them, but these are all Azure services
Everything within a project, environment or company should be named as consistently as possible so you'll never have to think about that.
I know it's a utopia to be completely consistent, but you should at least get it right in one product.
So why does Azure not do that?
And even worse, why oh why can it only allow lower case characters (and not even special characters) in 2019?
Abbas (name) - Wikipedia[^]
My name comes from a power tool... Just kidding, it's a popular Dutch name (an actual sander is called a 'schuurmachine', which loosely translates to 'friction machine' or, of course, a sander)
It comes from Alexander[^] which means something like "Defender of the People"
|
|
|
|
|
Sander Rossel wrote: it's a popular Dutch name (an actual sander is called a 'schuurmachine', which loosely translates to 'friction machine'
That's rough!
Sander Rossel wrote: Everything within a project, environment or company should be named as consistently as possible
If only! Integration between existing systems require (rather force) you to adopt multiple naming conventions. Just as you have ideas for better naming conventions so does all the developers of these platforms. It's almost impossible for all these developers to agree on the same thing. Now if you were to build something from scratch where selection criteria for third party tools is dominated by naming conventions...! That wouldn't leave you much options.
I agree there should be one universal naming convention for all languages, but that is simply impossible, not because it can't be done. But because everyone has different ideas about them and none of them wants to back down. I know I wouldn't! if I wrote something similar I'd defend it to the end of the Earth, i.e. until I fall off the edge.
|
|
|
|
|
Abbas A. Ali wrote: That's rough! Hah! The joke nearly went over my head
Abbas A. Ali wrote: selection criteria for third party tools is dominated by naming conventions...! I have seen products that use inconsistent naming conventions, that usually means that's not the only thing that's wrong!
Between systems is always difficult, but I guess in that case it's just not possible, but you can still be as consistent "as possible".
Abbas A. Ali wrote: I agree there should be one universal naming convention for all languages, but that is simply impossible I'm not even saying there should be one convention to rule them all, just that at least in a single product it should be.
I love how ASP.NET handles it, on the .NET side I send new { MyProperty = "Some value" } to the front-end and in JavaScript I magically get an object { myProperty: "Some value" } .
So I can use my PascalCasing in .NET, but I get my camelCasing in JavaScript, as things should be
And it goes the other way around to!
It's just a simple serializer trick, of course, but quite effective.
|
|
|
|
|
I mentioned earlier this week in some message thread here somewhere in the lounge that it's been a while I've blown the dust out of the NUC sitting on my desk...and that while initially it was whisper quiet, nowadays it took very little CPU activity to get the fan running at full speed and stay there. Sensor readouts, if they're to be believed, held steady at 80+ Celsius, and I literally couldn't hold it in my hand because it was just too hot.
After months of putting up with that, I finally took the time this morning to take the cover off and blow the dust out of it. There didn't seem like much, but it's making all the difference in the world...it's now been a few hours, cores are holding steady at ~50-55 Celsius, and I still haven't heard the fan kick in even once.
So even though it should be common sense, here's a friendly reminder: Do your devices a favor, and take the time to periodically blow that dust out, even though you might think the exterior looks fine.
|
|
|
|
|
Something strange happened to me today.
My laptop got up and blew the dust off of me!
Reminded me that I should get up once in a while
|
|
|
|
|
+5
/ravi
|
|
|
|
|