2015-11-26

On International Company Culture in The Netherlands

This was written on 2021-11-26 but it is retro-dated so as to not appear among my recent posts, and thus avoid embarrassing certain unnamed entities.  It is written in past tense even though a few paragraphs down the page it begins describing my current experience, because in the near future I intend this to become my past experience.

In 2015 I decided to leave Greece and its destroyed economy, and to go live and work elsewhere in Europe. I started an international job search, and within a couple of months I had a few offers to choose from. I picked the one from a company called Topdesk, in the nice little university town of Delft, in The Netherlands, mainly because of tax benefits available to expats in that country, but also, and in no small part, because The Netherlands has the reputation of being one of the most foreigner-friendly countries in Europe. The Netherlands achieves this reputation in a number of ways, one of which is the fact that the Dutch rank number one in the world (1) in English-as-a-foreign language proficiency, making it possible to live in The Netherlands without ever having to learn Dutch.

So, Topdesk brought me to Delft with all expenses covered, and even though as a foreigner I represented a trifling minority of maybe 2% of the employees in the office, my colleagues did an excellent job of helping me integrate, which is definitely something I am grateful for.  

For example, as I entered a room, they would all switch from speaking Dutch to speaking English among themselves, even if some of them were just discussing how their weekend was. That's how sensitive they were towards having a foreigner among them and making that foreigner feel included.

Later I worked for another company, also in Delft, where more than 50% of the employees were non-Dutch, so obviously, virtually all spoken and written communication in that place was in English. The impression that I formed was that when the Dutchies had a rare chance to speak Dutch among themselves, the foreigners were likely to think "let the poor folks speak their own native language for a change!".

Then later, the seemingly impossible happened: I somehow managed to find myself in a workplace which, despite also being located in Delft, did not have a sufficiently foreigner-friendly culture. I was amazed by how sharply I felt the difference; it really made me appreciate the international culture of the previous workplaces.

I suppose that the difference can be fully attributed to the fact that this particular workplace was a branch of a larger company which was headquartered outside of The Randstad area of The Netherlands. I have delved outside the Randstad a few times, and there is indeed a noticeable change in the varieties of Dutchies observable out there: things tend to be less international, people who struggle with English are actually common, and there is a decidedly more rural look and feel to everything, including the mindsets.

In this particular company I did once communicate with a headquarters employee who was in fact struggling with English, and mind you, I am talking about a person holding a high position in the high technology sector. How this is possible, I do not know. Apparently, the company is accommodating towards employees who are not comfortable with English, and as a result they attract employees that are not comfortable with English, so it is a vicious cycle. This culture appears to overflow to other branches, even in areas of The Netherlands where English fluency is the norm.

Here is an example of a very foreigner-unfriendly situation that I came across once, in the Delft branch:

My colleague next to me tells me that our code is causing something unexpected to appear on his screen, and asks me to come take a look. So, I roll my chair from my desk to his desk, I take a look at it, and we start discussing it. Another colleague overhears the discussion, and joins. The three of us continue discussing in English for a few more minutes or so, and then suddenly the two of them switch to Dutch. I am left sitting there waiting to see if they will switch back to English, but no such thing seems to be happening. After some more wondering what my purpose in life is, I quietly roll my chair back to my desk, while they are still discussing the problem in Dutch.

Now, I am not saying that either one of them had the intention of offending me, nor am I blaming them for not realizing that their behavior would be offending to me; this is the type of thing that may easily go unnoticed by everyone but the foreigner. However, from an organizational point of view this lack of anyone to blame means that situations like this cannot be corrected by expecting individual employees to take the initiative to adjust their own behavior and their own sensitivities; it can only be corrected by having a company culture which promotes international workplace awareness. That particular company decidedly had no such culture.

Of course, that was one of the most glaring examples of things going wrong, and it was not happening very often. There were, however, many other things which were less glaring, but they were occurring more frequently, some even on a daily basis, contributing to making the overall experience of working in that place unpleasant. 

For example, in that company there were talks and presentations every once in a while on various subjects related to our work, most of them physically taking place in the headquarters but available in Delft via videoconferencing. Many of them were being conducted in Dutch so I was excluded. Some were announced in English, but when I would join I would invariably discover that they were also being conducted in Dutch. In theory I could interrupt them and ask them to switch to English, but I was unwilling to do so, because the company culture gave me no such mandate. When the head of the company gives his yearly talk in Dutch, he sets a precedent. When many of the communications that arrive every week in my inbox are in Dutch only, this sets a precedent. When e-mails contain an English-translation but their subject lines are nonetheless in Dutch, this sets a precedent. When non-Dutch speakers are being treated as second-class employees, not by salary or by nature of work, but simply by communication, this sets a precedent. That is how company culture is formed.

Working for that company made me realize that my earlier colleagues at Topdesk were doing above and beyond what was necessary to make me feel included, and in that sense they may have actually been spoiling me. Of course, I do not expect anyone to switch to English just because I happen to be within hearing distance. As a matter of fact, not being able to understand Dutch can be considered as an advantage, because it allows my ears to easily cancel the environmental noise and focus on my work. However, when I am invited, or otherwise included, or in any other way entitled to participate in a discussion, to deny me participation by speaking Dutch it is highly unprofessional.

Here is a checklist of things to look out for with respect to international employees in the workplace:

  • If you post a job advertisement in English, and in the list of requirements you refrain from including knowledge of the Dutch language, and an international candidate shows up, and you hire them, you are essentially promising a job that can be performed in English. 
    • So, this is an obligation you have now picked up, which you must fulfill. 
    • There is very little that the employee can do to foul up their end of the deal; it is not like they can start submitting their work in Swahili tomorrow, and expect you to cope with it.
    • It is only the employer's end of the deal that can be either done right or fouled up.
  • In the high technology sector, these individuals have not come to The Netherlands asking for favors or "willing to cope with adversities".
    • They are highly valued professionals fulfilling important roles. 
    • These jobs are available not because Dutchies are unwilling to do them, but because there are not enough Dutchies around to do them. 
    • So, it is best if these individuals are not made to feel like fruit-pickers.
  • Any and all verbal communication directed to a group of employees which may potentially contain an international employee should be in English. If the speaker is unsure about the composition of the group:
    • The speaker should either assume that the group contains international employees, or ask.
    • The speaker should not assume that the group does not contain international employees, and expect them to interrupt and request that their presence be taken into consideration.
  • Words spoken in the presence of an international employee, and in the context of work, (such as in a live or virtual meeting,) should be in English, regardless of:
    • Whether these particular words are work-related or not.
    • Whether the words are deemed relevant to the international employee or not.
    • Whether the meeting has started or we are still waiting for everyone to join, etc.
The international employee is present in the meeting as part of their job, so professional rules of engagement apply.
  • Any and all written communication directed to a group of employees should be in English, not just for the narrow reason that the group may potentially contain an international employee, but more broadly, because that is what having an international company culture means. If Dutch must also be included:
    • The Dutch text may of course precede the English text, but it should not fail to begin with "=== ENGLISH FOLLOWS ===".
    • Both texts should have an equivalent status in all other respects, including formatting, pictures, etc.
    • For e-mail, subject lines should always be in English.
  • Mistakes that will inevitably be made need to be detected, corrected, and prevented from being repeated. For example, a newly hired employee may write an e-mail introducing themselves in Dutch only, and send it to the entire branch.
    • The correction in this case consists of management asking that employee to re-send the e-mail, this time translated in English. 
    • For this to happen, management must be on the lookout for such mistakes.
    • For this to not be repeated with the next fresh hire, management must examine what it is about the hiring process that fails to get the message across that there are non-Dutch speakers working in the company.  (Hint: simple measures, like changing the predefined e-mail signature from "Met vriendelijke groet," to "Kind regards," can work miracles.)
  • Any and all written communication that for whatever reason must be in Dutch should be in a format which facilitates single-click machine translation, because it may fall in the hands of an international employee, (even at some point in the distant future,) who must be able to very easily make sense out of it even if only to discover that it is irrelevant to them.
  • Any web sites or applications that international employees must regularly use should be 100% in English, without requiring machine translation, not even single-click machine translation.
    • This includes not only the messages displayed by the application itself, but also all verbiage added by means of data entry.  For example, it is not of much use to have the header of a table translated from "type velof" to "type of leave" if the entries in the table still contain words like "bovenwettelijk". 
    • Doing this right might require purchasing world-class software and investing in its customization; this is a price that must be paid in exchange of the benefit of hiring non-Dutch speakers. 
    • Doing this right may also require consultation with labor law experts, taxation experts, etc., and this is also a price that must be paid in exchange of the benefit of hiring non-Dutch speakers.
  • If the employee must choose the English language from a menu, they should not have to do that more often than maybe once every couple of years. Tools that offer a language choice only for demonstration purposes, without actually remembering the user's preference, are unacceptable. Sometimes fixing such a tool to make it behave correctly is seen as a feature request which gets filed along with other feature requests, prioritized according to how many users need it, and acted upon accordingly, meaning, never. Having an international company culture means giving such feature requests a very high priority.
  • Employment contracts should ideally be in English. If a company finds it hard to provide international employees with contracts in English, then each printed contract in Dutch should be accompanied by a copy in electronic form, along with a statement affirming that the electronic copy is identical to the printed copy, so that the employee can at the very least have it machine-translated so as to make sense out of it.


(1): English-as-a-second-language proficiency world-wide top rank in The Netherlands: See https://www.ef.nl/epi/

2015-10-21

The Mother of All Bugs

Michael Belivanakis 2015

At some point in my career I was working for a company that was developing a hand-held computer for the area of Home Health Care. It was called InfoTouch™. The job involved daily interaction with the guys in the hardware department, which was actually quite a joy, despite the incessant "it's a software problem --no, it's a hardware problem" arguments, because these arguments were being made by well-meant engineers from both camps, who were all in search of the truth, without sentimentalisms, egoisms, vested interests, or illusions of infallibility. That is, in true engineering tradition.

During the development of the InfoTouch, for more than a year, possibly two, the device would randomly die for no apparent reason.  Sometimes it would happen once a day, other times weeks would pass without a problem. When it happened, no matter how hard we tried, we could never reproduce it.  Also, some times it would die while someone was using it, but other times we would come into the office in the morning to find that it had died during the night, while sitting on its cradle, doing nothing but charging.

2015-10-18

Computer telephony in C++ with MFC

Back in 1999-2000 the state of the art in computer telephony was called Interactive Voice Response (IVR).  Nowadays when we speak of "voice" we usually mean voice recognition, but all that those telephony systems did back then was to playback recorded messages and wait for the caller to press digits on their phone. Sometimes, we would ask the caller to speak on the phone, and we would record their voice, for a human operator to listen to later.

The hardware had special filters on it to recognize the DTMF digits, probably because the CPU was thought of as too wimpy to do it by itself.  I experimented writing WAV-file processing filters on my own, and discovered that it took less than 10% of CPU time per phone line to run such filters in software, so it could certainly be done, but then again there existed systems out there in configurations of 30 or even 100 lines per computer, and of course the CPU was not enough in these cases.  We only worked with configurations of four lines per computer, but still, since the filters were made available by the hardware, I made use of them for the work project, and I only re-invented the wheel at home, for fun.

My employer at that time managed to secure a number of computer telephony contracts for a couple of big clients; he gave me a rough description of what the projects were supposed to do, and he had my coworkers slide pizza under my office door for as long as it took me to complete them.  He probably charged his clients the equivalent of a dozen programmers for this, and it was all done by me.  The only external help that went into these projects was messages recorded by a professional at a recording studio.

What follows is some screenshots of the telephony application that I created to run these projects, in Microsoft Visual C++ using MFC and the Dialogic Telephony API.

All applets waiting to start. Click to enlarge.

Crossword Puzzle Compiler

Techniques demonstrated:

  • Solving an intractable problem using a scoring heuristic
  • Super-indexing data structures for ultra-fast domain-specific queries

Summary (just gimme the TL;DR)


This is old-style artificial intelligence in action, solving within seconds a problem that would normally take eons to complete.

You give it a crossword grid, and a long list of words, and it finds ways to mesh words into the grid so as to form a complete crossword puzzle.  The final working version was done in 2003 using C# version 1.2 with a minimalistic UI in WinForms. 

The following 30-second video shows the crossword compiler in action, filling multiple successive crosswords using a word list taken from actual crosswords that have been published on the interwebz by various sources through the years.  The video is in real time, showing that the crossword compiler is, in most cases, extremely fast.


2015-10-04

Portfolio

I added a page where I list posts on this blog that can collectively serve as my portfolio.

It can be found here:

Michael Belivanakis - Portfolio



2015-09-25

Is my mentor's concern for code quality excessive?

There is this question that was asked on Programmers SE on Jun 12, 2015 which I answered, and as a result I received plenty of reputation, as well as a silver badge. Unfortunately, after a few days the question was closed as primarily opinion-based and then deleted.  Since I now have sufficient reputation to view deleted questions, I was able to find it, and I am posting it here for posterity.

Is my mentor's concern for code quality excessive? [closed]


Score: 75 (79 upvotes, 4 downvotes) Favorites: 28

To tell you a little about myself: I'm a newbie programmer working internships and learning a lot from experienced programmers. I can't believe I used to think I was good in college.

The one I'm doing right now is pretty great due to the amount of time and resources that the company is putting into helping and mentoring me and another intern. I'm learning a whole lot and for the first time, I feel like I get close to being competent.

The only "problem" are the massive code quality concerns of one of my mentors. It's to the point that anything takes a whole lot of time because I have to find the best way to do it or else it's a waste of time. It also feels like my creativity doesn't matter because there is only one right way to do everything. I don't mind any of this at all but I wonder, and this is mainly what I'm asking, if it's normal in the industry.

Also, when I get assigned a little feature and this guy reviews my code, he actually reviews the whole codebase I'm working on, pointing out loads of mistakes, most of them from before I was even hired. I have spent this whole week fixing code (that worked) written by their full-time programmers, even some things that are best practice according to other mentors.

Tags: [] [] [] []

asked Jun 11 2015 at 18:51 by CyborgFish
The question received 14 answers before it was closed.

The highest ranking answer was by Thomas Junk, with 130 points (gold bage is awarded at 100 points.)

The next answer was mine, with 71 points. (silver badge is awarded at 25 points.)

Here it is:

2015-09-14

Why Oracle Sucks

Oracle talks a lot about 11g Express Edition, and how it differs from the full (paid) versions of their database, but it does not say a word about the most important thing:

Is it compatible at the SQL syntax level?

No way to find out other than to try it.  So, let's try it.


2015-07-28

Woohoo! One more of my "Programmers SE" answers has received a score of -5 !

The question is on a controversial topic, and as usual, I take the controversial stance.  So, it is no wonder that people do not agree with me.

Here is the question:

programmers.stackexchange.com: Does it make sense to use “ys” instead of “ies” in identifiers to ease find-and-replace functionality?

2015-07-26

How to: Completely disable "Aero" in Windows 7

So, with Windows 8 sporting these god-awfully ugly opaque square boxes, which are not adorned in any way whatsoever, (not even the decent in all its simplicity gradient of Windows 98,) it seems like a confession on Microsoft's behalf that the spiffy "Aero" look of Windows 7 was nothing but an unnecessary gimmick afterall.

So, are you sticking with Windows 7 but want to disable Aero in order to enjoy considerable gains in performance, memory, power consumption, and GPU temperature? Here is how:
  1. Open up "Services". 
  2. Locate the service "Desktop Window Manager Session Manager". 
  3. Disable it and stop it. 
Enjoy!

2015-07-25

How to: Disable the administrative shares in Windows

To disable the administrative shares in Windows, (default shares like C$, ADMIN$, etc.) follow these steps:

1. Run the Registry Editor and go to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet \Services\LanmanServer\Parameters
2. Create a new DWORD, name it AutoShareWks, and leave the default value of 0.

3. Reboot Windows.

This will disable things like C$ and ADMIN$.

I am not sure how to also delete print$ and IPC$.  ("net share ipc$ /delete" appears to work temporarily, but the share automagically re-appears after the next reboot.)

How to: Enable the Administrator account in Windows

To enable the Administrator account in Windows:

1. Open up an elevated command prompt.  (If you do not know what this is, you should not be even thinking of enabling the Administrator account.)

2. Type the following command:
net user administrator /active:yes

2015-07-20

Solved: Windows: WiFi connect immediately after boot and before logon

In order to have your windows computer connect to your favorite WiFi access point immediately after booting, (without you having to first login to your computer,) follow these simple steps:

1.  First of all, make sure that this computer has connected before to the WiFi spot of interest.  (A so-called wireless profile is created as a result of this manual process.)

2. Run cmd.exe and issue the following command:
netsh wlan show profile
3. In the list of wireless profiles that are displayed, locate the one you want, and copy its name to the clipboard.

4. Run regedit.exe and navigate to this key:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
5. Add a string value to this registry key.  Name it anything you like, and give it the following value:
%comspec% /c netsh wlan connect name="<profile name>"
Voila, next time you restart, your computer will immediately connect to this WiFi spot if it is in range.

Many thanks to user Soumya of superuser.com for posting this:http://superuser.com/a/133935/111757

2015-07-14

Solved: cannot eject USB device: "This device is currently in use."

Millions of people all over the planet continuously have this problem: they try to eject their USB drive so as to avoid data loss, but windows does not allow them.  Which is very frustrating, because whatever reasons windows thinks it has for not allowing the removal should have lower priority than the user's explicitly stated direct wish to remove the damned thing!

Anyway, suggestions for solutions abound on the interwebz.  Here are some that I found with a quick search:

1.  Put your computer to sleep.  When going to sleep, Windows flushes all buffers to all devices, so while the computer is asleep, it is safe to remove the device.  The problem with this approach is that I don't want to have to put my bloody computer to sleep each time I want to take a USB device out.

2. Use SysInternals Process Explorer to search for the drive name, find which process has a handle open on the drive, and terminate it.  The problem is that drive names are only one a letter and a colon, a search for "D:" may yield thousands of handles from several dozen processes, all of which are unrelated to your drive "D".  Unfortunately, Process Explorer does not offer any option to search for a whole word only.  Another problem is that this approach hardly ever works.  Apparently, there are ways in which devices can be locked which do not show in Process Explorer.  Even if you remember to launch it as Administrator.

3. Select "Quick removal" policy as opposed to "Better performance" policy in the drive properties. The problem with this is that it is not really a solution: we generally do specifically want the better performance, and we are willing to sacrifice quick removal for it, accepting slow removal instead. But this issue is not one of slow vs. fast removal, it is about not being allowed to remove your device at all, ever!

Here is the solution which worked for me, after the above failed:

4. Make sure that the drive, or any folders in it, are not shared on the network!  (Use "NET SHARE" on the command prompt to quickly find out what you are sharing.)

Solved: The network folder specified is currently mapped using a different user name and password

So, I am on computer A, trying to map a local drive to a shared folder of computer B, and Windows gives me this message: "The network folder specified is currently mapped using a different user name and password".  

Microsoft supposedly addresses this issue here: https://support.microsoft.com/en-us/kb/938120 and concludes that it is so by design.

Bullshit.  They are missing the point.  The error message is wrong.  The network folder specified is not currently mapped using a different user name and password. Instead, what is happening, is that another folder of the same computer B is already mapped on computer A using a different user name and password. 

So, apparently, with windows, if you connect from computer A to any share of computer B, then all subsequent attempts to connect from computer A to other shares of computer B must be done using the same credentials.  Go figure.

2015-07-13

The GWX (Get Windows 10) KB3035583 trojan horse

So, Microsoft has pushed this trojan horse to every single user of Windows on the planet.  It displays a Windows 10 logo on the taskbar, and it is basically telling you that not only you will get Windows 10 as soon as it comes out, but you should right now begin acting as if you are looking forward to it. Because, you know, you are their biatch.

So, let's see:  a) GWX installs on your machine without your consent; b) once installed, you cannot "quit" it or "exit" it; and c) you cannot find it anywhere to uninstall it.  So, it fits squarely within the definition of malware.

GWX is delivered by means of an innocent looking optional update, KB3035583.  The update is designated as "Recommended", and its description says "Install this update to resolve issues in Windows. For a complete listing of the issues that are included in this update, see the associated Microsoft Knowledge Base article for more information."  (I am not making this up, that's exactly what it says, I suppose English is not their forte at Microsoft.)

Of course, with dozens upon dozens of updates each time you check, which give you no clue as to what they are about, and instead each one of them refers you to some web page for more information, you don't bother checking, and so you passively consent to this trojan horse being downloaded and installed on your computer.  If you click on "More information", you are taken to a web page which admits that update KB3035583 is nothing but an incredibly lame and stupid publicity stunt about the upcoming Windows 10.

And so, as it turns out, that bit about resolving issues in Windows was a fucking lie.

How to get rid of the KB3035583 trojan horse:

1. In Windows Update select Change settings, and make sure that "Give me recommended updates the same way I receive important updates" is unchecked.  This way, the fact that this is a "Recommended" update will not cause it to jump from the "Optional" updates list to the "Important" updates list.

2. In Windows Update select View update history, find KB3035583, and uninstall it.

3. In Windows Update click on "Check for updates".

4. In Windows Update go to Optional Updates, find KB3035583, and specify that you want it to be hidden.


And then in 2017 there is this:
betanews.com: Microsoft will never again sneakily force Windows downloads on users
(Though it is unclear to me whether this is about Germany only or the whole world.)

2015-07-09

Remote Desktop Connection quits without a word

So, I am firing up a remote desktop (RDP) connection, and the little box appears saying that it is trying to connect:


And then the box just disappears, without an error message or any other hint as to what might have gone wrong.

The interwebz abound with reports of this happening, and people asking how to fix it, and various solutions being offered that range from the complex to the hopelessly complex.

Luckily, every time I have encountered this problem, the solution for me was very simple: just wait and try again later.  The remote computer is probably busy booting, or perhaps booting and installing updates.

Now, I will tell you a little secret: when something goes wrong, software can ALWAYS give a meaningful error message.  If it does not, then someone, somewhere, is being either EVIL or INCOMPETENT.

If it could not find the server, it would have said that the server was not found.

If the server was not responding, it would have said that the server is not responding.

In this case, the server was actively refusing the connections, and someone at Microsoft was either so evil that they decided that in this specific case the software should not say anything, or, more likely, someone at Microsoft was so incompetent that they could not simply write their world-class software to give a meaningful error message in a very frequently occurring usage scenario.

Intel NUC5CPYH incompatible with Windows 7 Ulitmate 64 bit?

Intel advertises NUC5CPYH - (Celeron N3050) as being compatible with Windows 7.  It is not.  All my attempts to install Windows 7 Ultimate 64 bit on it failed.  The installation would start, and when it would reach the first interactive screen (language selection) the keyboard and mouse would be dead, (not even NumLock would work on the keyboard,) even though both keyboard and mouse work fine on the BIOS screens of the NUC.  On other occasions I managed to overcome this problem, (I don remember how,) and the installation would proceed to 99%, only to fail in the end with some error about not being able to update my computer's boot configuration or something.

Edit: be sure to read nucblog's comment below for a link to an article with instructions that might bring you more luck than I had.

In general, my overall experience of interacting with the BIOS of the NUC5CPYH was not pleasant at all.  The spiffy looking BIOS screens were not welcome by me, as they were not structured in the perfect logical order that I would expect of them, and certain parts of them were clunky.  Attempts to introduce an aesthetic upgrade which result in something technically more flawed than its ugly predecessor generally make a very bad impression, at least to me.

Perhaps the most annoying thing is that the initial screen with the prompts to press F2 to enter setup, F10 to enter the boot menu, etc. appears as if it requires not one, but two key-presses.  It probably requires only one, but there is an initial period of time during which if you press a key, that key is ignored, and that's extremely annoying.  Hey you, Intel BIOS programmers, I have a hint for you: if you are not ready to accept key-presses, do not display a prompt for them!

2015-04-30

On dogma in engineering

I once had a colleague who had a higher rank than me, and who was not only unconvinced by my rational and articulate arguments for doing a certain thing in a certain way, but he concluded the discussion by stating that --and I am not paraphrasing here, this is what he actually said-- the way he wanted it done was mentioned in a book, so unless I could find a book backing up my proposal, it was to be done his way.

I did not argue with him at that time, (how can you argue with that?), but I would now like to quickly jot down my thoughts on why saying such a thing is incredibly stupid:
  • Engineering books are there for you to learn things from them, not to be taken as truth by revelation.
  • An engineering book makes (or fails to make) a point by analyzing it in detail until it is self-evident that the point holds true, not by proclaiming the point and putting the name of the author underneath it.
  • The value of an engineering book lies in providing justification for the claims that it makes, not in making the claims available as ink impressed onto paper.
  • Therefore, engineering books are supposed to help you win arguments by equipping you with valid points to bring in defense of your positions, not by playing the books as trump cards.

For all I know, you may have read the whole book and misunderstood every single bit of it, or you may be completely wrong about the applicability of the points made in the book to the particular situation that you have at hand.

So, unless you can use what you have learned from a book to reason, any insistence on things written in a book on the grounds that they are written in a book is blatantly stupid dogma.

Of course, I understand that other concerns may be at play. For example, that particular guy, having been tasked with being a team leader in a team of relatively senior engineers while being only in his early thirties, and having knowledge of the fact that he is good at his job but not stellar, he was probably insecure about the possibility of large scale project failure, in which case (so he thought) he wanted to be able to save face by claiming that he had followed "best practices", and here are the books to prove it.  Oh, the cowardice.

Wow, 5 upvotes, 10 downvotes and counting

I have this answer on programmers.stackexchange.com which, at the time of writing these words, has 5 upvotes and 10 downvotes, and in all likelihood it will continue collecting downvotes, while I adamantly refuse to remove it, standing 100% by my ideas. I am dumbfounded, as such a thing has never happened before.

Here is the programmers.stackexchange.com question:

Is it okay to have objects that cast themselves, even if it pollutes the API of their subclasses?


I have a base class, Base. It has two subclasses, Sub1 and Sub2. Each subclass has some additional methods. For example, Sub1 has Sandwich makeASandwich(Ingredients... ingredients), and Sub2 has boolean contactAliens(Frequency onFrequency).

Since these methods take different parameters and do entirely different things, they're completely incompatible, and I can't just use polymorphism to solve this problem.

Base provides most of the functionality, and I have a large collection of Base objects. However, all Base objects are either a Sub1 or a Sub2, and sometimes I need to know which they are.

It seems like a bad idea to do the following:

for (Base base : bases) {
    if (base instanceof Sub1) {
        ((Sub1) base).makeASandwich(getRandomIngredients());
        // ... etc.
    } else { // must be Sub2
        ((Sub2) base).contactAliens(getFrequency());
        // ... etc.
    }
}

So I came up with a strategy to avoid this without casting. Base now has these methods:

boolean isSub1();
Sub1 asSub1();
Sub2 asSub2();

And of course, Sub1 implements these methods as

boolean isSub1() { return true; }
Sub1 asSub1();   { return this; }
Sub2 asSub2();   { throw new IllegalStateException(); }

And Sub2 implements them in the opposite way.

Unfortunately, now Sub1 and Sub2 have these methods in their own API. So I can do this, for example, on Sub1.

/** no need to use this if object is known to be Sub1 */
@Deprecated
boolean isSub1() { return true; }

/** no need to use this if object is known to be Sub1 */
@Deprecated
Sub1 asSub1();   { return this; }

/** no need to use this if object is known to be Sub1 */
@Deprecated
Sub2 asSub2();   { throw new IllegalStateException(); }

This way, if the object is known to be only a Base, these methods are un-deprecated, and can be used to "cast" itself to a different type so I can invoke the subclass's methods on it. This seems elegant to me in a way, but on the other hand, I'm kind of abusing Deprecated annotations as a way to "remove" methods from a class.

Since a Sub1 instance really is a Base, it does make sense to use inheritance rather than encapsulation. Is what I'm doing good? Is there a better way to solve this problem?

Tags: java, inheritance, type-casting
asked by codebreaker


2015-03-20

Mandatory disposal vs. the "Dispose-disposing" abomination

This article started as a stackoverflow answer, and then I copied it over here to expand on it.

For a discussion of the same issue but in java-oriented terms, see this stackoverflow answer of mine: Is overriding Object.finalize() really bad? http://programmers.stackexchange.com/a/288724/41811

There is this practice which is unfortunately very prevalent in the C# world, of implementing object disposal using the ugly, clunky, inelegant, ill-conceived, and error prone idiom known as IDisposable-disposing. MSDN describes it in length, and lots of people swear by it, follow it religiously, write walls of text discussing precisely how it should be done and precisely how it works, and precisely how they arrived at this particular way of doing it, etc.

(Please note that what I am calling ugly here is not the object disposal pattern itself; what I am calling ugly is the particular idiom of implementing an extra Dispose method with a bool disposing parameter.)

This idiom was invented under the assumption that the invocation of IDisposable.Dispose() is something optional, or in any case something which might be OK to forget, in combination with the fact that it is impossible to guarantee that our objects' destructor will always be invoked by the garbage collector to clean up resources.  So, people tend to make their best effort to invoke their IDisposable.Dispose() methods, and in case they forget, they also give it one more try from within the destructor. You know, just in case.

2015-03-13

Solid State For The Win!

These two screen captures are from CrystalDiskMark measuring the performance of my brand new Samsung 850 PRO 256GB Solid State Drive (C:) versus the performance of my old Seagate Barracuda 1TB 7200 RPM 32MB Cache Hard Disk Drive (D:).  Higher numbers are better.


Both devices are capable of SATA III, but my machine only has SATA II.  Under SATA III I would expect the HDD to perform somewhat faster, but the SSD to perform a lot faster.  I will update this post when I upgrade to SATA III.

SSD, where had you been all my life?

2015-03-03

Minimal MySQL Memory Footprint

The following image shows the mind-boggling amount of memory occupied by MySQL 5.6 server on Windows 7 64-bit.


(This is despite the fact that during installation I explicitly specified that this MySQL server is going to be used for development, not for production.)

A quick search on the web shows that this preposterous amount of memory can be reduced to something less preposterous by editing my.ini (usually found in some place like ProgramData\MySQL\MySQL Server 5.6\) and replacing the following line:
table_definition_cache=1400

with this line:
table_definition_cache=400
Unfortunately, even though the savings are huge, the memory footprint of mysql is still nothing short of gargantuan: