aspose file tools*
The moose likes Meaningless Drivel and the fly likes I wanted to aks this: How much code You can write without testing? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Meaningless Drivel
Bookmark "I wanted to aks this: How much code You can write without testing?" Watch "I wanted to aks this: How much code You can write without testing?" New topic
Author

I wanted to aks this: How much code You can write without testing?

Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
Sometimes I can write for a day, or even few days without compilation, like when I want to make a sketch. After that comes the seriouse trouble. When I do that I know that I will be desperate later, but I love it so much like that sometimes.
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Interesting question. I often find myself doing proof of concepts on my playground project/environment. They rarely contains any tests unless it is actually a test framework or theory I am playing around with. However, when then implementing it into a real project or incorporating it into code base, I try to do TDD.

The advantage of having 10+ years of coding experience and most often being in the role of an architect is that you get away with it and can just present a concept that other (read younger) developers have to implement.
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
Thanks thanks very much.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11422
    
  16

I never write more than 10 lines before re-compiling. I seriously try to never write more than 2-3 before re-compiling.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

It depends. For trivial testing programs I usually write the whole thing before compiling and running. For serious projects, I compile every few lines.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

I'm with fred. Every few lines, certainly never more than a method. Especially if it's client-side stuff.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Last year, when I started doing web development, I went more than two months without ever testing on Internet Explorer. I was under the impression that Javascript is Javascript, how different can Firefox, be from Internet Explorer, Safari, Chrome, or Opera?

Sheesh, that was a mistake. Tons of code. Works fine on FF, but not consistently anywhere else. It took more than a week to clean the mess up.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Note: the title is not accurate, most of the question and answers are about compiling. Having code that compiles does not mean that its tested.

I tend to compile often. Rather than think in number of lines, I think about complexity. I can throw out a for-loop that searches for something without thinking, no need to compile.

But on topic: As soon as I have the fundamentals of a class defined, i.e. most of the member variables, the constructors and major methods, I have my IDE generate the JUnit tests for the class. And I immediately make the tests real, adding implementation code as needed to make the junit tests pass.

Both the class and the Junit test get checked into the repository (these days 'git'), and get committed like voting in Chicago, early and often.
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
I know how to program, I've never really done it for real, few years ago I finnaly decided not do anything else, but I allways feel like I know so much anyway. Contrary to that, for example JTree took me unbelivable big time, together with anything connected to JTree, so when I took JList, I allready got used on something irational about this things. First time that I went to do "forum reader" I had to go through many other things, all in all, understanding ecosystem, at that time I was still wishing to do "what if" things, like all the memory is in my hand, so to understand what is what I don't know I had to learn how it is called what I wish, it took me seriouse time to concentrate on how it is supposed to be. Few days ago I went to make "forum reader" again, this time knowing in advance all that I need, and I wanted to incorporate it into my application, but first I went to make a prototype alone. It took me a day to make a working prototype. But putting it in my application is totally different story, becaouse I am stretching my designers capabilities, it's different, it has to do many things, and the whole application has to be "magically" modular in design and all. Today I am working on a prototype of "forums live feed", too much slow but ockay, I'm listening Pixies. Sometimes when I do for days something it takes me a day to start to think about something else. Today or tommorow I'll start to assemble the whole application, and then I will go through redesign. Now I have a lot of "material", a working code, that I can "cut". I think that I can get significantly faster, but I will never be able to make it as fast as I would like it to be. When I was young, one older programmer told me that proffesional programmers, he said, for example in Borland, that they make three lines a day, but that it only has to be flawless, and they have very enough money for house on a lake. It's really not like that, not three lines. Three lines is so nothing. I don't know. At least I think so. I am constantly tweaking my self. I am not sure if I am still making some most seriouse systematic error, but If You all compile at few lines then I'm not wrong when thinking that it is like that. I like to stretch it on more lines if I can, but I am not good enough for that, so I just try to get a feeling where should I be the most efficient, how You do it...
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
Thank You very much Pat Farrell, very much.
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
The title is like that, little here little there, becaouse, also... and that's big thing for me... I am not doing yet unit tests, but I think that I will reborn when I start to do it... Also, I don't write JavaDoc yet... i do things only for my self, so I don't have to do anything..
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Petar Thomas wrote:The title is like that, little here little there, becaouse, also...

Actually, I was going to tell you your title is silly. But then, this is MD. If you have a question, ask it.
As written, your title says " I want to ask about testing, but I'll ask about generics and embedded systems instead"

Petar Thomas wrote:and that's big thing for me... I am not doing yet unit tests, but I think that I will reborn when I start to do it... Also, I don't write JavaDoc yet... i do things only for my self, so I don't have to do anything..


Real programmers write Javadocs and Junit tests. Good IDEs make it easy. Do it as you write the code. There is never time to go do it later.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18675
    
    8

In these days when we have IDEs to help us do our work, there's no excuse for writing a big lump of untested code. But back in the days when you had to write your code on special squared paper and give it to an underpaid clerk to type it onto punched cards, writing a thousand lines of untested code was a normal occurrence.
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
Aha, "testing" like that.

Yes, yes, maybe on other forum I wouldn't write it like that. I have many old-school old-fashioned concepts, and I never relly wanted to be a proffesional in anyhting, but I have started when I was nine in assembler and though I never was enough seriouse to sit in front of the computer for more than a year, or few months, I have never stopped to think about it, so I have small billion of thoughts that I don't know how to express corectly, and I know about quite much things how it has to be done, but I never do it becaouse then I wouldn't have time for what I am interested, except that now I am trying for a while to make it all right. : )
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
I understand.
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
Then... If I can write my code withouth unit tests and without testing with quite much too much errors like my code is a throusers in a flood... how much is slowlier to write it on a right way? And how much is needed more concentration for that? And... How much is normal to be done per day, but with JUnit tests? (, becaouse, I imagine lot's of people are working without good tests, for what I do think it is not good..)
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Paul Clapham wrote: But back in the days when you had to write your code on special squared paper and give it to an underpaid clerk to type it onto punched cards, writing a thousand lines of untested code was a normal occurrence.


When I started programming, you got one, (1), run of your program per day. One shot to fix the compilation and logic errors. Back then, you desk checked your code. And I mean seriously desk checked your code. Fred Brooks, of Mythical Man Month fame, says that the use of an IDE and the rapid edit/compile/debug cycle was one of the biggest improvements in programmer productivity in the history of computing.

Even with that, I'm not sure that writing thousands of lines at a time was normal. I'll believe 100 or even a small number of hundreds.

Personally, I never got into the writing it on special paper to be keypunched. I did my own punching. Hunt and peck, back then guys did not take typing classes. I did learn to program the 029 so it would auto-skip to place a C in column 7.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18675
    
    8

I'm pretty sure I once submitted 900 lines of code to be keypunched. I remember that because I was cross-eyed for the next two days. Which was okay because I had to wait that long for the punched cards to come back.
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
No excuses
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Petar Thomas wrote:.... how much is slowlier to write it on a right way? And how much is needed more concentration for that? And... How much is normal to be done per day, but with JUnit tests? (, becaouse, I imagine lot's of people are working without good tests, for what I do think it is not good..)


The point of writing a program is to get working code.

How much slower is writing it which way? With or without Junit tests?
I believe, IMHO, etc. that a programmer produces a working program much more quickly with unit tests. The time to write the unit tests is small, and the improvement in quality of your code is huge. With proper JUnit tests, your code stays working as it ages and is modified.

Google for Agile Programming, or Test Driven Development. There are thousands of articles and hundreds of books on the topic.
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
I am trying to understand some specific things about OO programming and design, how to say, to connect the way I'm thinking with what is... It's like, I can't stop thinking, but I have too little in fingers... and I feel like it is... that I am so close to have .. one application that I have made.. so that I can test one hundert important ideas i have about programming, oo programming (like bond, james bond)... and I think then I will be "free"... to work on the next things which are important... this things, "production"... and technologies, apis, and so...
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
I believe, IMHO, etc. that a programmer produces a working program much more quickly with unit tests. The time to write the unit tests is small, and the improvement in quality of your code is huge. With proper JUnit tests, your code stays working as it ages and is modified.


Yes, that...

But I was really thinking on how much lines without testing like starting the program. In this context, no Code can be written without testing... But I was also interested in feeling how people fuctionate and do it, in small detail focus... Like, what's the feeling of being a proffesionall programmer... Do people write ten lines, twenty.. a class, a method... like, when is the moment "to wake" and make a "reality check"... I don't know... Somehow I felt it important.. It's like, with JUnit test, the picture is a little bit more complicted... You know, it's like, I have never been inside the office where are the programmers, for longer than a minute... and I am so much inloved in programming... This is, like.. it helps me to bridge the gap. It helps me to imagine the working place. I am supposed to start to work proffessionally, I am 33... And I have many problems to look like a seriouse candidate for a job... I'm kind of slow... I know for testing for a long long time, and I have thousands of my ideas for testing, and thousands of ides for everything. But I didn't really had a computer allways, so it was all just thinking, lots of times papers and drawings, so what I have are realy a lot of ideas, just ideas, but not bad ones... It's only that when I speak with a real programmer, i slip on the practical things, and even the enthusiasm and all the good things I have, are working against me, becaouse instead of looking smarter or more capable, I look totally opposite... So, for me it was, this.. like a quiz question...maybe someone feels fine to write something, bit realxing maybe, maybe not too seriouse, and I get the feeling about the people, but also something what , for the fact is , I belive, very valuable to me..
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
... And it really was a question about how many lines... Simply how many lines?

The question was not so much about compiling and testing, but it was about how many lines in a sense like if You have a "programming sentence" when and where do You check was the first part of the thought correctly written, becaouse it concernes the difference between the single thought and the written program. So, when do You check if You are still in a Zone?


JUnit, and all is also part of it. And I am very thankfull for input, and nudge.
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
Like for example... Sometimes I'm a smoker, and then I am not for weeks and months, then also I don't drink coffie, so when I don't smoke I'm quite much calmer with nicer concentration and I can make out more complicated things, but when I drink too much coffie then I "test" very often, especially if I am listening music, even, if I am thinking on something else, I forget where I am, so for example then I even have to restart a program to see where I stopped. Sometimes I totally love my program, and sometimes it seams to me meaningless, last time it seemd to me like bunch of text around (now I have only text). It's only when I think on the details is when I am inloved with it.
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
It's obviouse. No?
The frontman of Black Sabath, I think not Motorhead, told that being in a band is different than other jobs, becaouse when You come to stage so much drunken that You can't walk, everbody says: "Yeah, tonight it will be so good.". When I was playing sax tenor sometimes being in the Zone ment half a liter of the wors chemical vodka before even seeing anyone, and then it just starts. If it's of concern, I don't drink for years, but also I don't play. Once the Norton Child Protect Something, that I tried, didn't give me to see Java Ranch pages, and it writted out that this is the site for selling beers.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Having spent a lot of time in my younger days playing in bands, I never met anyone who played better when drunk or stoned. I met a lot of people who *thought* they played better that way, however!

On topic: somebody has to test every line of code you write. If it's not you, then in a lot of places these days it'll be a user. Who would you rather find your bugs? And the more often you test, the easier it is to do. I never write a method w/o testing it.


[Jess in Action][AskingGoodQuestions]
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
Come on people. This is too much.
I've readed around tens of thousands of technical text in last three years.
This topic was exactly about what Pat and Paul and maybe Ernest say that it is not.
This topic is exactely what Ove Lindström , fred rosenberger , Stephan van Hulst , Bear Bibeault and Henry Wong understod well that it is.
I overreacted, and my joke about Black Sabath and alchohol was just stupid joke, but come on...
I never met anyone who played better when drunk or stoned. I met a lot of people who *thought* they played better that way, however!



I salute You with the song Blume from Einstürzende Neubauten
http://www.youtube.com/watch?v=FPLoRt2CG_U&playnext=1&list=PLB8D6888CC54DF92E

I am too much ashamed. Good bye.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18675
    
    8

It's like this: I'm a professional programmer, so more than 90% of my work is maintenance of existing code. So there isn't much code-writing going on there. As for the other 10%, that mostly involves writing code which is extremely similar to something which already exists, so I cut-and-paste rather than writing new code.

So in other words, although I spend a lot of time programming, I spend very little time writing code. That means I really can't answer the question.
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1277

The whole application


No Kaustubh No Fun, Know Kaustubh Know Fun..
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8829
    
    5
does the code have to run?

I can write a lot if it doesn't have to compile!


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

I know that this was probably intended as a joke, but I'll respond to it seriously...

Bert Bates wrote:
I can write a lot if it doesn't have to compile!


I can't. I get bored too easily. This is why I tend to design applications in components. This way, I don't have too spend too much time doing pseudo code stuff.

Probably has drawbacks, but I need feedback -- and that is running code. Even if it is a small component of the future application.

Henry
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
@ Ernest Friedman-Hill
For me it is hard to think about stoned or drunken musitians and about programming in the same time. From what You have written here, that means that You have an opinion on that from the first hand. When You implied Your self allready, I can tell that I don't like that language. I don't like language in which is said that someone else *thought* that playing stoned or drunken is better, becouase that sounds like "They thought they were cool", or basically what it seems to me that You've stated is that You don't like that idea that "being drunken and stoned is cool", but You haven't said it simply like that, what You've said is that You were "there" and basically, what You have written here points that You know something about something that it maybe is even illegal, and simply, till what measure did You just implied Your self as a part of something illegal while trying just to say that being drunken and stoned is not cool? I cant take this as a sober and mature attitude. Did those people who You are talking about searched for help, did they died, did You helped them? What happened? Did You called the police? About what are You talking about? Simply the thing is too much seriouse to be able to talk like that about it. If You wanted to say that being stoned and drunken is not cool, much more uncool is to have such an attitude about people who get drunken and stoned. Question is "Do You care?". There are many ways to help people. Maybe You do care, I don't know. But I am assuming that Your job is not working with drug addicts nor with drunken people. I have worked on the documentary about the places where the drug addicts get cured and I know all there is to know about it in my country. That thing is so sad, and it is not nice how You are speaking about so sad thing.
I think that in Your language this is called "squared", but I like "squared", that's why I am sorry, if the right word is "squared" that this was not squared enough. This was just easy. I simply don't like to talk about it like this. I can't even find a morale in it.


@Paul and Pat
Thanks. I'm all right with all except with patronising, directing, etc., unless I have to be all right with that also.

@Bert Bates
What You have written here sounds like similar to writing books, like if You don't have to compile, it is similar like writing books.

@All
Thank You a lot.

@Henry Wong
Thanks.


I do things like this.
I am constantly checking with println here and there, then erasing that line and continuing. I don't like that I do that. NullPointerException is my only friend.
Recently I gave up on trying to make anything that doesn't let it self to be made immediatelly. I just don't have any more time and I am passed some point so now I know that if I continue skipping over something that later it will be clear to me what to do, with more gathered experience, and in the same time I don't have to stop on one line for a week. Now I got that feeling about that. I remember that I used to have exactely that feeling about the dynamics of how I am developing my self and calculating with it.
I think that I am suppose to be able to make an application on such a way to construct model of application and then put in with adapters or something the real classes, but I simply can't make it right. It annoys me that I can't do that. Like, if I don't know how something really looks a like, I have a good idea how it is supposed to look a like, so I should be able to leave space for it and make all the things around, but I can't.
I also do a lot of copy paste but in a way that with that I am avoiding to make things more tight, I have unneceasary code all over my app, but I don't mind that. I will come back for that. I also leave as much as I can old code that I replaced with anything new, I just put it in comments. I like it to sit there. Lots of times I let the lines of the code to be exactely as how I writted it, a little bit less logical but showing the exact steps I made and how I have thinked about it, so I can see what I was thinking, and how.
I am constantly leaving out moments where I could program more bravely, making constructions that I have clear in my mind. That's maybe the most critical thing. Also, I find OO programming very powerfull, and one piece of the problem that I don't do it more bravely is that I don't explore what I could do. There is so many things that I could do with factories and designs.
This all fits so well, for me, into the subject of "how many lines of code You can write without testing". Like, if I have some more brave idea, can I write it in one run, or I have to write piece by piece, becaouse the best effect what I could do is to write it at once and then see what I got.



john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

I usually compile every 50-100 lines, depending on what I'm working on. If it's something trivial, then I'll wait until the end. If it's something big, I'll finish a section and then re-compile.
cc11rocks


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Petar Thomas
Ranch Hand

Joined: Oct 11, 2009
Posts: 234
Hm. That sounds promising. : )

[edit]
Elton John - Blue Eyes
http://www.youtube.com/watch?v=2pil9raVqYs
 
permaculture playing cards
 
subject: I wanted to aks this: How much code You can write without testing?