|
ClementsDan wrote: I hadn't learned about arrays yet
I on the other hand...
In my first programming course (using BASIC-Plus on a PDP-11) one of the assignments was to do something (I forget what) with a bunch of numbers and it was expected that we would use a bunch of individual variables. But I said to myself, "there's gotta be a better way", and proceeded to read the next chapter of the book, which covered "subscripted variables" (arrays). So I wrote my program using them and turned it in. The teacher replied, "that's next week's assignment!"
|
|
|
|
|
I remember CanDo!!!
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
Cool
|
|
|
|
|
Tak wrote: if not rect.PointInRect(point) or control.IsDisabled() then
DoNothing()
else
... # Some real code here
endif
I think you knew more about programming than you realized. You were obviously thinking about future extensions and nice features you could add within the DoNothing function. I bet if you had to continue to work on the game today you would be happy the handy DoNothing you put there many years ago. And people would be wondering, how could someone be so brilliant when he was only 14 or 15?
|
|
|
|
|
One of my proteges[^] is working for a company who swears that the "best" way to do TDD is to write the code first, and then make the test pass AFTER everything has been written. He has pretty much done everything he possibly could to convince the management and his coworkers that they've got it all backwards, but they insist that they don't need to learn anything about patterns since their Oracle Framework (which is a Developer Preview edition, btw) 'does all the work of patterns for us'.
Here's a sample snippet of their work. It's in Java, so beware of the hanging curly braces:
public void doFind(){
log.debug("Search records");
DCBindingContainer bc = (DCBindingContainer)getBindings();
DCIteratorBinding ib = getBindedIterator(bc,TABLE_ITERATOR);
AdfFacesContext context = AdfFacesContext.getCurrentInstance();
String pScope = context.getProcessScope().get("strAction").toString();
log.debug("Process scope = " + pScope);
if(pScope.equalsIgnoreCase("advanceSearch")){
log.debug("Do advance search");
ViewCriteria vc = ib.getViewCriteria();
Row row = vc.first();
row.refresh(Row.STATUS_INITIALIZED);
if(codeFrom.getValue() != null &&
!codeFrom.getValue().equals("")) {
if(codeTo.getValue() != null &&
!codeTo.getValue().equals("")) {
row.setAttribute("ApInvcTypeCode",
" between '" + codeFrom.getValue() +
"' and '" +
codeTo.getValue() +
"'");
}else {
row.setAttribute("ApInvcTypeCode",
" like '" + codeFrom.getValue() +
"%'");
}
}else{
codeFrom.setValue(null);
}
if(latinName.getValue()!=null && !latinName.getValue().equals("")){
row.setAttribute("ApInvcTypeLatinName",
" like '" + latinName.getValue() + "%'");
}else{
latinName.setValue(null);
}
if(arabicName.getValue()!=null && !arabicName.getValue().equals("")){
row.setAttribute("ApInvcTypeArabicName",
" like '" + arabicName.getValue() + "%'");
}else{
arabicName.setValue(null);
}
if(effStartDateFrom.getValue() != null &&
!effStartDateFrom.getValue().equals("")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if(effStartDateTo.getValue() != null &&
!effStartDateTo.getValue().equals("")) {
row.setAttribute("EffStartDate",
" between '" + sdf.format(effStartDateFrom.getValue()) +
"' and '" +
sdf.format(effStartDateTo.getValue()) +
"'");
}else {
row.setAttribute("EffStartDate",
" = '" + sdf.format(effStartDateFrom.getValue()) +
"'");
}
}else{
effStartDateFrom.setValue(null);
}
if(effEndDateFrom.getValue() != null &&
!effEndDateFrom.getValue().equals("")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if(effEndDateTo.getValue() != null &&
!effEndDateTo.getValue().equals("")) {
row.setAttribute("EffEndDate",
" between '" + sdf.format(effEndDateFrom.getValue()) +
"' and '" +
sdf.format(effEndDateTo.getValue()) +
"'");
}else {
row.setAttribute("EffEndDate",
" = '" + sdf.format(effEndDateFrom.getValue()) +
"'");
}
}else{
effEndDateFrom.setValue(null);
}
}else{
log.debug("Do basic search");
}
OperationBinding ob = bindings.getOperationBinding("Execute");
ob.execute();
ib.setFindMode(false);
getChangesFlag().setValue(0);
AdfFacesContext.getCurrentInstance().getProcessScope().put("strAction","");
}
To add insult to injury, their "Senior Level" developers supposedly have two to three years of experience, and yet, they have problems understanding recursion; to them, it's practically a black art. They don't understand what refactoring is, nor do they spend any time reading any programming journals or articles online unless there's a problem in their code that they can't fix. The sad thing is that my former apprentice has to put up with these people, and they dismiss his "crazy" advice from books such as the Mythical Man Month as pure hogwash. They insist that since they have their application "framework", they don't need to worry about reading any useless books--it does everything for them.
I can't publicly say the name of the company, but if you happen to do any outsourcing in the Philippines and want to know the name of this company so you can avoid it, send me a private message, and I'll tell you exactly who it is.
The moral of the story: If you're going to outsource to any company, make sure you get some thorough code samples of their work before paying them a cent. Otherwise, you just might end up with a company like this.
|
|
|
|
|
Philip Laureano wrote: The moral of the story: If you're going to outsource to any company, make sure you get some thorough code samples of their work before paying them a cent. Otherwise, you just might end up with a company like this.
*sob*
I mentioned something earlier today about perhaps interviewing the new consultants before setting 'em loose on our apps. No such luck.
But who is the king of all of these folks?
|
|
|
|
|
Tell him that if it was supposed to be that way they would have called it Development Driven Test (DDT) instead
|
|
|
|
|
I'm a great fan of shorties. I'll have to miss most of the source for the usual reasons, but the last two lines made me do a double-take...
(within class FeedMetaData, C#)
virtual FeedMetaData Send(FeedValidationErrorHandler handler)
{
this.Dispose();
return this;
}
|
|
|
|
|
Return value should be FriedMetaData then :P
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Another shorty, discovered moments after submitting the last, and in the same file.
Console.WriteLine(String.Format("{0}", arg));
Again, the actual example is slightly more complex, but I'd guess that there's a redundant call in there somewhere
|
|
|
|
|
Huh... not arg.ToString() ?
|
|
|
|
|
uh, no, it should be Console.WriteLine("{0}", arg); (The string.format("{0}", arg) is superflous.
The reason to use the format specifier is that arg may itself contain formatting directives such as {0}.
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
I first read that as FeedMeData...
|
|
|
|
|
Thank God I wasn't the only one!
|
|
|
|
|
Just like dangling pointers in C or C++
|
|
|
|
|
Is that like Premature Eja....?
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
I found this moving a project from visual studio 2003 to 2005.
void RemoveChars(CString& Str, const char* pChar)
{
int iLen = Str.GetLength();
if ( !iLen )
return;
char* szStr=Str.GetBuffer(iLen);
ASSERT(szStr);
WORD iDest;
WORD iSrc;
iDest=(WORD)::strcspn(szStr, pChar);
while( iDest != ::strlen(szStr) )
{
iSrc = (WORD)::strspn(szStr+iDest,pChar);
if( iSrc )
{
::strcpy_s(szStr + iDest, iLen, szStr + iSrc + iDest);
}
else
{
*(szStr+iDest) = '\0';
}
iDest=(WORD)::strcspn(szStr, pChar);
} // while
Str.ReleaseBuffer();
}
|
|
|
|
|
Not very horrific, but I think it is kind of cute:
#define UNUSED1(a) a=a
#define UNUSED2(a,b) a=a,b=b
#define UNUSED3(a,b,c) a=a,b=b,c=c
#define UNUSED4(a,b,c,d) a=a,b=b,c=c,d=d
What use could these UNUSED functions possibly have? Well, I
had to ask one of the other programmers. If you have unused
parameters in a functions parameter list, a warning occurs
"unused parameters in the parameter list" or something like
that. How to get rid of those pesky unused parameters? Call
the UNUSED function with those unused parameters. The UNUSED
function will use the unused parameters, making them used
parameters instead. Now no warning for unused parameters will
occur! Problem solved!
|
|
|
|
|
this is a common practice.
you can do either one of the following :
void MyClass::MyMethod( int i, CString& s )
{
UNUSED( i );
UNUSED( s );
}
or
void MyClass::MyMethod( int , CString& )
{
}
or
void MyClass::MyMethod( int, CString& )
{
}
|
|
|
|
|
I'm sure it's "common practice", but why have unused parameters in the first place? It's aint right, I tells ya!
|
|
|
|
|
This is not correct.
When using a given framework, one can't choose the functions signature.
Sometimes we only need to know when an event has occured, but extra information is given which we don't need.
You could hide all warnings with the #pragma directive but that is dangerous, because that will hide alsoo the correct warnings.
Therefore you should remove/comment the parameter from the function signature or use the parameter.
Most compiler will ignore the a=a line when builded so there is no speed constaint.
I preffer to comment the unused paramters out
codito ergo sum
|
|
|
|
|
BadKarma wrote: Therefore you should remove/comment the parameter from the function signature or use the parameter.
You can also get the harmless warnings.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Ahh just start ignoring those harmless warnings...
That way lies madness!
I'm pretty sure I would not like to live in a world in which I would never be offended.
I am absolutely certain I don't want to live in a world in which you would never be offended.
Dave
|
|
|
|
|
Automatically VS2005 generated code:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
Actually it is just deceiving compiler to avoid warnings.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
for example, in MFC :
you have a message handler for the Left button down :
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
In my code ( or yours ) you might not need to use the nFlags parameter, so you do something like :
void CMyWindow::OnLButtonDown(UINT , CPoint point)
{
}
|
|
|
|