Purely Fabricated Interview Expert Pattern

Posted in Slagare internationale, Stand-up philosophy on February 21st, 2011 by Mihnea

Am aflat de la Andrei Ignat ca Scott Hanselman a publicat o noua lista de intrebari de interviu pentru programatori. Cred ca Hanselman asta e un fel de Ovidiu Cucu international, ca vad ca tot publica liste d-astea. Ca orice programator care se respecta, si eu sint constient ca pot deveni somer peste noapte, deci fac eforturi mari sa ma tin la curent cu ultimele evolutii in domeniul intrebarilor de interviu. Atasez mai jos raspunsurile mele la intrebarile lui, pentru cei 3 cititori din totalul nostru de 5 care nu sint membri pe programare.org. Scuzati limba lu’ Shakespeares, am zis sa nu break character.

What is SOLID?


Why are patterns important?

Patterns are important because people who cannot program must be able to project importance by wielding pompous words.

Who are the Gang of Four? Why should you care?

The Gang of Four, also known as The Alpha Wankers, are four non-programmers who understood what power words are and applied the concept to programming. I care because Aurelian Popa told me that today it is more important to be “social” than to know how to program, and using pretentious jargon like “singleton” instead of “global variable” is a guaranteed way of improving one’s social status. They are not to be confused with the Wang-Zhang-Jiang-Yao group, whose name they borrowed in a spectacularly ill-advised stab at self-irony.

Explain the concept of Separation of Concerns and it’s pros and cons.

Separation of Concerns means that when you concern yourself too much with design patterns, you can stop being concerned about grammar. No man can understand the singleton pattern AND remember the basic rules of languages with immensely complex grammars such as English, so once you embrace the teachings of the Gang of Four, grammar becomes Somebody Else’s Concern. The first sign of this transcendence is putting an apostrophe in the possessive pronoun “its”.

Discuss the concept of YAGNI and explain something you did recently that adhered to this practice.

YAGNI is something YAGN, as it’s related to XP.

Are you still writing code? Do you love it?

No, I’m too busy calling my global variables singletons and speaking at conferences about it.

What do you do to stay abreast of the latest technologies and tools?

Hahaha you said breast!

How do you react to people criticizing your code/documents?

I punch them, fire them and/or write inflammatory posts about them on forums or blogs.

Whose blogs or podcasts do you follow? Do you blog or podcast?

Are blogs and podcasts design patterns? Never heard of them. Anyway, I like the color fuchsia, I am an open-minded person focused on self-improvement and my hobbies include hiking, music, reading and taxidermy. I hope this helps you determine if I’m a good programmer or not.

What is the last programming book you read?

I only ever read one, “Design Patterns”. I memorized every word. I don’t need to know anything else.

What’s so great about <cool web technology of the day>?

<generic answer>

How can you stop your DBA from making off with a list of your users’ passwords?

I didn’t know such sexual deviationism is so common among DBAs and anyway, why is that my problem instead of HR’s? Oh wait, you said “making off”, not “making out”. My bad.

What do you do when you get stuck with a problem you can’t solve?

The Design Patterns book is a complete list of solutions which are just waiting for problems. Unenlightened people approach programming the wrong way: they see problems and look for solutions. I use the sure-fire method of picking solutions from The Book and inventing problems for them. That way, I’m never stuck. Any feature or system which cannot be implemented in this way is ill-defined and not worth my concern in the first place. See also the “Separation of Concern” principle.

What’s the difference between a web server, web farm and web garden?

Wait, what? Web garden?

When do you know your code is ready for production?

When I have at least 157 design patterns in it.

What’s YAGNI? Is this list of questions an example?

Didn’t you ask this already?

Noile mele cuvinte favorite: Information Expert (a nu se confunda cu Code Expert), Pure Fabrication, Protected Variations.

LE (adica Later Edit, Ovidiu): hahahaha am aflat ce-i ala web garden. Redefinirea cuvintelor limbii engleze, in pula mea.

LLE: GoF au incercat sa si cinte la un moment dat. Punk, pentru ca si la muzica se pricep la fel de bine ca la programare. Iata-i aici prezentind pattern-ul “Old Grey Whistle Test”:

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Sa nu-ti faci array cioplit

Posted in Codare cu premeditare on August 5th, 2010 by Mihnea

Deci imi scapa ceva, deci. Deci a facut colegu’ bascalie de Silviu “Traffic Sign Recognition” Ardelean, da’ se pare ca de fapt Silviu chiar avea dreptate propovaduind lumii tehnologia pe care tocmai o inventase. Deci sa va explic.

MVP Marius Bancila, care parea cel mai breaz dintre codexperti, a pus pe blogul dinsului o aplicatie pentru torturat oamenii cu dicromatism. Implementarea acestei aplicatii presupunea manipularea unui array bidimensional. Privind in sursele puse la dispozitie cu generozitate, observam urmatoarea abominatie:

int** m_pCells;
void Create()
   m_pCells = new int*[m_nSize];
   for(int i = 0; i< m_nSize; ++i)
      m_pCells[i] = new int[m_nSize];

Acu’ vreo doua zile imi zicea un prieten de un program scris de fizicieni care aproape si-a dublat footprintu’ cind a fost mutat pe 64 de biti din cauza ca autorii aveau genul asta de relatie contra naturii cu array-urile de pointeri. Azi vad ca problema nu e rezervata exclusiv refugiatilor din Fortran si juniorilor care aloca vertecsi cu new float[3], ci isi intinde tentaculele pina la virfurile comunitatilor de experti in C++ (auto-proclamate, ce-i drept). Acum nu ca in cazul de fata ar conta overhead-ul sau muile murmurate in barba de procesor la vederea festivalului de pointer chasing, da’ chiar imi scapa de ce ai scrie atita cod in plus, ca la sfirsit sa mearga si prost.

Avind in vedere ca tehnologia aia de tinut array-uri multidimensionale in vectori nu este atit de cunoscuta pe cit credeam, zic ca merita un loc in panoplia evidentului, adica sa fie transformata intr-un “design pattern” d-ala. Sa stea acolo la loc de cinste cu variabila globala, instructiunea switch si alte astfel de geme indispensabile inginerilor de pe tot globu’ de pamint. Ce zici bre Silviule, te bagi sa-i dai un nume in engleza?

Si daca tot am ajuns la subiectul patterns si best practices, sa observam si aceasta tehnica de programare defensiva:

CBrush* CColorMap::GetBrush(int key) const
   if(key < 0 || key > (int)m_brushes.size())
      throw std::exception("Invalid color key", key);

   return m_brushes[key];

Pe linga abila inlocuire a lui assert() cu throw, codul de mai sus demonstreaza si abila utilizare a unui constructor non-standard pentru std::exception care nu face tocmai ce se asteapta Marius sa faca. Din nefericire autorul nu s-a sinchisit sa stea si la primire, deci problema nu apuca sa se si manifeste, iar codul e chiar mai eficient in varianta asta obfuscata. Se pare ca pina la urma puroiul ala de Coelho avea dreptate.

Tags: , , , , , , , , , , , , ,