10 Replies - 937 Views - Last Post: 12 October 2018 - 07:57 AM

#1 Khinhp   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 06-January 17

can people fluke codes in java (programming)?

Posted 11 October 2018 - 03:19 AM

can people fluke codes in java and other programming languages in general? why does it work, and if this is a good programming practice?
Is This A Good Question/Topic? 0
  • +

Replies To: can people fluke codes in java (programming)?

#2 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3621
  • View blog
  • Posts: 16,638
  • Joined: 20-September 08

Re: can people fluke codes in java (programming)?

Posted 11 October 2018 - 03:33 AM

What does "fluke codes" mean?
Was This Post Helpful? 0
  • +
  • -

#3 Khinhp   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 06-January 17

Re: can people fluke codes in java (programming)?

Posted 11 October 2018 - 05:32 AM

View Postg00se, on 11 October 2018 - 03:33 AM, said:

What does "fluke codes" mean?

typing code you did not think you end up with it,

View Postg00se, on 11 October 2018 - 03:33 AM, said:

What does "fluke codes" mean?

typing code you did not think you end up with it, you did not do it on purpose
like I write code int a = 100;
fluke code like int a;
Was This Post Helpful? 0
  • +
  • -

#4 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3621
  • View blog
  • Posts: 16,638
  • Joined: 20-September 08

Re: can people fluke codes in java (programming)?

Posted 11 October 2018 - 06:18 AM

Well of course. That just depends on the level of understanding of the programmer doesn't it, to a large extent.
There are categories of common errors that could be called 'fluked code'. One that springs to mind is

Quote

if (a = 100) then { // (Not a comparison but an assignment)
// Do it
}

Was This Post Helpful? 0
  • +
  • -

#5 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6775
  • View blog
  • Posts: 27,938
  • Joined: 12-December 12

Re: can people fluke codes in java (programming)?

Posted 11 October 2018 - 07:30 AM

It is rare to type a piece of code by accident that happens to work, and work properly. Most often it is a mistake that needs to be rectified, and might remain undiscovered for a while.

A serendipitous example I can think of is to forget to call a method like .get() and discover, by accident, that indexing [4] works. These are minor, but pleasant, discoveries.

I cannot imagine someone creating several lines of working and syntactically correct code by complete mistake/fluke. A word or two, or omitting a method call, yes.
Was This Post Helpful? 2
  • +
  • -

#6 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3621
  • View blog
  • Posts: 16,638
  • Joined: 20-September 08

Re: can people fluke codes in java (programming)?

Posted 11 October 2018 - 08:23 AM

Yes, if 'fluked' means a positive outcome, then it would be very rare.
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14924
  • View blog
  • Posts: 59,580
  • Joined: 12-June 08

Re: can people fluke codes in java (programming)?

Posted 11 October 2018 - 08:45 AM

Pfffst.. I made a career on mashing random chunks of code together and getting some sort of output.

Definitely the blurst of times. :D :^:

Spoiler

Was This Post Helpful? 3
  • +
  • -

#8 cfoley   User is offline

  • Cabbage
  • member icon

Reputation: 2391
  • View blog
  • Posts: 5,021
  • Joined: 11-December 07

Re: can people fluke codes in java (programming)?

Posted 11 October 2018 - 05:29 PM

Can I mash the keyboard and get working code? Well, obviously not.

But...

Can I type get + [Ctrl][Space] and guess at the method I want?
Maybe, although I should check the documentation the first time and then use this feature as a reminder in future.

Can I see a compile error and get the correct result by using autocorrect blindly?
Maybe, although I should see what all the options do out of curiosity and then apply them mindfully. If you do this well, you can automate your imports, autogenerate most method signatures and perform several refactorings.

Can I keep adding code to some partially working code to get it to work a bit better?
There are entire careers built around this, unfortunately.

Can I write an AI to evolve working code?
Maybe. Give me the funds, the time and the team of people and let's find out!
Was This Post Helpful? 0
  • +
  • -

#9 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12556
  • View blog
  • Posts: 45,682
  • Joined: 27-December 08

Re: can people fluke codes in java (programming)?

Posted 11 October 2018 - 05:47 PM

Let's move this to the lounge!
Was This Post Helpful? 0
  • +
  • -

#10 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6817
  • View blog
  • Posts: 23,191
  • Joined: 05-May 12

Re: can people fluke codes in java (programming)?

Posted 11 October 2018 - 09:33 PM

View PostKhinhp, on 11 October 2018 - 06:19 AM, said:

can people fluke codes in java and other programming languages in general? why does it work, and if this is a good programming practice?

Yes, but it is not a good practice. Code reviews are supposed to catch things like this.

Quote

Programs must be written for people to read, and only incidentally for machines to execute.
- Harold Abelson, Structure and Interpretation of Computer Programs


So even if something maybe syntactically correct, it may not make sense to a human reading the code when they are doing a code review.

A code review should have caught Apple's goto fail problem.
Was This Post Helpful? 0
  • +
  • -

#11 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11450
  • View blog
  • Posts: 19,521
  • Joined: 19-March 11

Re: can people fluke codes in java (programming)?

Posted 12 October 2018 - 07:57 AM

Just a reminder: in English, "code" in the sense of "instructions written for machine execution" is a mass noun and therefore does not take a plural.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1