• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

List of alleles/genotypes

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello! I'm trying to make a list of 1000 beings (listed as "male") and assign a genotype (randomly) to each of them. The end goal would look like:

Male 1: 0/1
Male 2: 0/0
Male 3: 1/0
And so on.

The goal is then to do this to another set called "Female". Then, I would essentially mix the two and have one allele from the "male" and one allele from the "female" randomly assigned to a new "offspring".

I am very new to Java coding and know only the basics. I apologize for my horrible coding in advance.

So far I have only figured out how to randomly determine genotypes, but not assign them to a male 1, male 2, etc. This is fine if I want to copy paste them into excel and assign them there, but I was hoping to contain it all within the code.

I'm really not sure where to start, though I thought arrays may be a good place. Does anyone have resources or ideas about how I could go about this project?

Could I please receive some guidance on what I could use/ resources I could read to:
A). Contain all the males, females, and offspring genotypes so I can print them and get an easy to read list?
B). Take a genotype randomly between the males and females to get a genotype for the offspring?

Thank you in advance!

What I have so far, which is redundant and messy is below. It only gives a list that I could then paste into excel and work with there.
 
Marshal
Posts: 79466
379
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Your coding is much better than you think, but the forum software seems to have taken the leading spaces from the first line only.
If you want to assign a value at ransom, you can use Math.random(). I usually avoid Math.random(), preferring the Random class, but in this situation it will work nicely. For example, setting a number with a 30% probability:-You probably don't need an else because you already have the value 0 set. I think you don't need the two doubles.
Put some spaces around the operators in line 8, for example.
 
Master Rancher
Posts: 4920
74
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:If you want to assign a value at ransom


Note that we normally do not condone holding values for ransom, here at the Ranch.

Campbell Ritchie wrote:You probably don't need an else because you already have the value 0 set.


I think she does, given the way the code is currently structured.  Note that the values are initialized outside the loop.  If you set a value to 1 inside the loop, how will you ever set it back to 0?

Serenity, I see some repeated code in there that can be cleaned up - which will help as your project gets bigger.  Consider, could you make use of a method like this?

This same method could also be written:
 
Mike Simmons
Master Rancher
Posts: 4920
74
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Serenity Quinn wrote:I'm really not sure where to start, though I thought arrays may be a good place. Does anyone have resources or ideas about how I could go about this project?

Could I please receive some guidance on what I could use/ resources I could read to:
A). Contain all the males, females, and offspring genotypes so I can print them and get an easy to read list?
B). Take a genotype randomly between the males and females to get a genotype for the offspring?


For A, you probably want to break it down into two subtasks:

A1) Combine the 2 alleles for one male or female into one record of some sort.  
A2) Contain 1000 male records into something like a list, and contain 1000 female records into another list.

For A1, you probably want to learn about how to create a simple Java class.  Perhaps you'll want to create a Male or Female class, or a single Person class (since so far the data for both looks the same).  Or perhaps what you want at this point is a BasePair class, since so far you're just talking about a pair of two alleles.

If learning how to make a class seems like too much at this point, you could also use a simple array of ints, size 2.  That may be enough.  But, you will probably find the class approach more flexible as you add more code later.

For A2, you can either use an array, or a List - probably an ArrayList.

For each of these, there are a variety of resources out there - I strongly suspect that wherever you learned how to do what you've done so far, there's more chapters available.  I'm just trying to outline some key areas to look for.  Historically, many of us have learned from Oracle's Java Tutorial.  Many people also like the book Head First Java.  There are many others available as well.  But wherever you've learned from so far, it seems like a good source.  We've seen plenty of other "beginners" who are in much worse shape.
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Simmons wrote:. . . we normally do not condone holding values for ransom . . .

Hahahahahahahahahahahaha!
Condoned or not, the ransom is $3845634853945639465934659364596.

I think she does, given the way the code is currently structured.  . . .

Yes; I was mistaken there.

This same method could also be written:

I prefer that way to write that method, even though beginners are often scared of the ?: operator.
You could also have the alleles as objects; I think the best way to do that is to make an Allele1 enum. allele1 = Math.random() < probability ? Allele1.A : Allele1.B;
 
Serenity Quinn
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for your guidance! I am going to play around with these ideas, these are new techniques for me!  
 
Ranch Hand
Posts: 32
2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd create a separate class for Being with allele represented by booleans (why waste int for 0/1 values?). And store Beiings in separate ArrayList for male and female:



Output
>java Genotype
Male
0/0
0/0
1/0
0/0
0/0
0/0
1/1
1/0
1/1
1/1
Female
1/1
1/0
0/1
1/0
0/0
1/1
1/0
1/0
0/0
0/1
 
Mike Simmons
Master Rancher
Posts: 4920
74
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Grzegorz Wilanowski wrote:I'd create a separate class for Being with allele represented by booleans (why waste int for 0/1 values?).


Well, I agree that boolean may be more appropriate if only two values are possible.   However, behind the scenes, using an int probably won't be wasting any more space than a boolean - Java usually implements booleans with a full 32-bit or 64-bit word (usually the latter, nowadays).  It's just simpler for most operations.  The only time you really see a boolean taking one bit (in memory) is in a boolean array - those are sized pretty much as you'd expect, probably rounding up to the closest multiple of 32 or 64 bits.  That may be an important consideration later if it becomes necessary to operate on very large data sets (which is known to happen in genomics).

Anyway, that sort of optiization and behind-the-scenes analysis is probably beyond what the original poster needs at this point.  Serenity, feel free to ignore.
 
Sheriff
Posts: 17652
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At the risk of sounding pedantic, if you're going to represent these as objects, then you might as well do it according to their definitions.

An allele is a specific copy of a gene, while a genotype identifies the alleles related to a trait; it can also be extended to refer to the entire set of genes of an organism.

What I'm not sure about is this whole probability thing. From what I'm reading about alleles and genotypes (https://www.biologyonline.com/dictionary/genotype), it's about possible combinations. But then again, with blood types, type O is the most common even though it's made of recessive alleles. If you're representing alleles as 0 and 1 and assuming 1 is the dominant allele and 0 is the recessive allele, then you'd have 11, 10, 10, 00 as your possible genotypes.

If I were to code this, I'd probably do something like:

Note that I've named the parameter as "dominantProbability" to be more explicit about which way the selection is biased rather than leaving it to the reader to figure it out from the implementation code.
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right to create a class to encapsulate those data. Otherwise you are simply moving into procedural programming.

Grzegorz Wilanowski wrote:. . . allele represented by booleans

Why? Memory is cheap; you won't get anywhere near the available heap size for 1,000 objects. Or maybe 100,000,000. You will probably run short before you reach 1,000,000,000 objects, however.

(why waste int for 0/1 values?). . . .

It's not a waste; it will allow you to introduce a third allele for each gene. You will have to refactor all your code if you only permit two possibilities. Of course, an allele isn't a number. Something is only a number if you can do arithmetic with it. So I think none of the primitive datatypes is suitable for that field. Least of all boolean, so I am disagreeing with Mike.
What you have is a set of objects, all different from each other, but only a restricted and predefined number of them. That looks to me like an excellent use case for the enum class type (also called enumerated type).
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A few minutes ago, I wrote:. . . enum class type (also called enumerated type).

Then I pushed submit instead of preview by mistake. So there is more to write.
* * * * * * * * * * * * * * * * * * * * *
An enum may be beyond OP's present experience, but I think it is the most object‑oriented way to implement her requirements. You can even combine the ordinal() method and toString() to get 0/1 (as Strings not numbers). I regard your method to convert booleans to numbers as awkward. Also the method to choose an allele takes Math.random() twice, and I think that means you get the alleles with 50% frequency each.
If you go beyond two elements, however, it becomes awkward to choose an allele. I suggest something like a static method getElementByProbability(double). You might implement that by iterating the array of choices and adding the frequencies of the alleles until you reach the probability value passed. That has the advantage of moving the choice into the GeneXYZ class, which I think is better because the class is taking care of itself rather than having other code do its work for it. It also means the enum needs a frequency field and all the frequencies need to add up to 1. You can find examples of all sorts of things about enums in the link in my previous post, and also in the Java® Language Specification. All enums implement all the methods in this class.
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A few minutes ago, I wrote:. . . the frequencies need to add up to 1. . . .

Well, allowing for the known imprecisions of the double datatype, those figures below do add up to 1.0.

Junilu Lacar wrote:. . . I'd probably do something like: . . .

That looks like what I was thinking of.To get ≥ write &ge; The bits about \u201c/d are posh quotes: “”.
I can see several possible problems about the method to get an instance. I shall let you work out what they are. No, the correct wording is, “Leave that as an exercise for the reader.”
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This morning, I wrote:. . . the frequencies need to add up to 1. . . .

In which case it would be best to change the name of the field in that post to frequency.
 
Junilu Lacar
Sheriff
Posts: 17652
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:I regard your method to convert booleans to numbers as awkward.


In what way is allele1 ? 1 : 0 awkward? If you're thinking that java.lang.Boolean is an enum type, it's not, so you won't be able to use ordinal() to convert FALSE to 0 or TRUE to 1. The expression is duplicated in that code but that doesn't make it awkward, in my opinion, just repetitive.

Also the method to choose an allele takes Math.random() twice, and I think that means you get the alleles with 50% frequency each.
If you go beyond two elements, however, it becomes awkward to choose an allele.


Again, I'm curious about the "awkward" characterization -- how so?

I think the way "probability" is given a pseudo-random value is misleading at best because as you said, that will still produce numbers that have "(approximately) uniform distribution"

You might implement that by iterating the array of choices and adding the frequencies of the alleles until you reach the probability value passed.


I don't think that's necessary since Java's built-in pseudorandom-number generators are designed to generate sequences that are uniformly distributed. You just need to introduce the condition to split the results along the bias. The (pseudo)randomness should take care of the distribution.  

It also means the enum needs a frequency field and all the frequencies need to add up to 1.


Not sure I follow this. Can you explain the rational behind such a field in more detail? And why would the total of frequencies add up to 1? Aren't frequencies cardinal numbers that denote quantities, not fractions?
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:. . . I don't think that's necessary . . .

It would be one way to implement choice if, as usually happens in real life, you get a gene with more than two alleles. Blood group is an example: you have the alleles A and B, as well as an allele not doing anything, which corresponds to group O.
There are bound to be other ways to implement such choice from > 2 elements.

Aren't frequencies cardinal numbers that denote quantities, not fractions?

No; if you get something happening half the time it has a frequency of 0.5. The frequency of the blood group allele O is about √0.4, which is something like 0.63.
Of course, those things would all be unnecessary if you only have two alleles.
 
Junilu Lacar
Sheriff
Posts: 17652
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:No; if you get something happening half the time it has a frequency of 0.5.


You're talking about frequency distribution in terms of percentages. (Absolute) frequency is the number of times an event occurs; that's a cardinal number. The two are not the same.
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, frequency distribution.
 
Junilu Lacar
Sheriff
Posts: 17652
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a small program to simulate ABO occurrences, with probabilities for each:

If you run this several times, you'll see the distributions stay pretty close to the probabilities specified. The pseudorandom number generator takes care of the distribution uniformity; the condition applies the bias.
 
Mike Simmons
Master Rancher
Posts: 4920
74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Posted in response to Campbell's last post, before seeing Junilu's ABO enum above.]

If you're talking about a double between 0 and 1 that represents the chance that a given element would be 1 rather than 0, I think I would skip the ambiguity of "frequency" and instead call it "probability".

As I did, back when I suggested
 
Junilu Lacar
Sheriff
Posts: 17652
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Simmons wrote:[Posted in response to Campbell's last post, before seeing Junilu's ABO enum above.]
If you're talking about a double between 0 and 1 that represents the chance that a given element would be 1 rather than 0, I think I would skip the ambiguity of "frequency" and instead call it "probability".


The "frequency" name is definitely throwing me for a loop.

On a side note, I've never seen that kind of annotation in a quote before. Very Chat GPT-esque, to be honest. Kudos to whoever added that feature!

Edit: I see where the annotation is coming from now. Wow, for a minute there I thought someone on the CR staff was really making good use of AI. Turns out it was just a timing thing. Maybe it'll be a while before AI will take our moderator jobs. LOL.
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:. . . The "frequency" name is definitely throwing me for a loop. . . .

My getting it wrong first ime doubtless didn't help
 
Mike Simmons
Master Rancher
Posts: 4920
74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:On a side note, I've never seen that kind of annotation in a quote before. Very Chat GPT-esque, to be honest. Kudos to whoever added that feature!


As you have probably worked out, I hand-edited the annotation myself, immediately after posting and seeing that some miscreant had inserted another post in between Campbell's post and my response.  My wife will find it very amusing that I have been likened to a program for simulating human conversation.
 
Junilu Lacar
Sheriff
Posts: 17652
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Simmons wrote:My wife will find it very amusing that I have been likened to a program for simulating human conversation.


My wife would probably find ChatGPT better than me at making small talk, or any kind of conversation for that matter.
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:. . . with blood types, type O is the most common even though it's made of recessive alleles.  . . .

A and B are the other alleles, which are codominant. They can both be expressed, in which case you get the type AB.
 
Grzegorz Wilanowski
Ranch Hand
Posts: 32
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Simmons wrote:using an int probably won't be wasting any more space than a boolean - Java usually implements booleans with a full 32-bit or 64-bit word (usually the latter, nowadays).)



To see how much memory boolean and int really take, I serialized objects to file and compared their size on disk.
That way, I found that int variable occupies 8 bytes in file and boolean occupies 5 bytes in file. byte also occupies 5 bytes in file.
So this implies that boolean takes the same amount of memory as byte what is 8 bits



with x variable being transient I get all files 31 bytes long

31 BoolAllele.txt
31 ByteAllele.txt
31 IntAllelee.txt

with x variable not transient, BoolAllele and ByteAllele increased both by 5 and IntAllelee increased by 8

36 BoolAllele.txt
36 ByteAllele.txt
39 IntAllelee.txt

 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Grzegorz Wilanowski wrote:. . . int variable occupies 8 bytes in file and boolean occupies 5 bytes in file. . . .

The Java® Language Specification says an int occupies 32 bits and doesn't specify a size for a boolean. Maybe the serialised version occupies different memory from that.
 
Campbell Ritchie
Marshal
Posts: 79466
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Simmons wrote:. . . I have been likened to a program for simulating human conversation.

My wife would find it even funnier if somebody said that about me.
 
Mike Simmons
Master Rancher
Posts: 4920
74
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Grzegorz: that's a good investigation of the size when serialized - but there's no reason to expect that that's the same as the amount of space used in memory.  In ancient times, we did this by using methods on java.lang.Runtime to measure the total memory being used, and creating large numbers of objects of different types, to measure how much memory those objects were using.  Nowadays it's possible to use the java.lang.instrumentation package for more precise measurements, and other techniques.  Here are a few links for you:

https://stackoverflow.com/questions/9368764/calculate-size-of-object-in-java
https://www.baeldung.com/java-size-of-object#:~:text=Objects%2C%20References%20and%20Wrapper%20Classes,a%20multiple%20of%204%20bytes.

It's been awhile since I did this myself, and I see one article is saying a boolean takes one byte in memory.  Probably that's what I saw years ago, and I misremembered - though it may have changed.  Regardless, it's unlikely that a boolean will only take one bit on your machine, unless it's in an array - or unless you're encoding the boolean into the bits of an int or long.
 
Mike Simmons
Master Rancher
Posts: 4920
74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:The Java® Language Specification says an int occupies 32 bits and doesn't specify a size for a boolean. Maybe the serialised version occupies different memory from that.


Serialization aside, I don't think the JLS says those are necessarily the actual values that will be used - but we can infer that 32 bits is the minimum size required, because you can't mathematically represent the full range of possible values for an int, with less than 32 bits.  I'm pretty sure that when it's evaluating expressions on a 64-bit machine, it's using a 64-bit value - but when it stores that value in a field on an object, it's using 32 bits for an int.  And apparently 8 bits for a boolean.  Though this stuff could vary from JVM to JVM.
 
Mike Simmons
Master Rancher
Posts: 4920
74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since this is about internal implementation, the relevant authority would not be the Java Language Specification, but the Java Virtual Machine Specification.  JVMS 17 2.3 consistently specifies the values each type must represent, but not the size of the memory to actually use.  So it's really unspecified, though the required value set does impose a minimum size on the implementation.
 
Saloon Keeper
Posts: 15630
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's completely beside the point.

Neither int nor boolean are good values to represent an allele with.

For instance, it doesn't make sense to say your ABO blood type is 'true true', or that it is '1 0'. I'd do something similar to Junilu, except I also have some other reservations there.

Junilu Lacar wrote:If you're representing alleles as 0 and 1 and assuming 1 is the dominant allele and 0 is the recessive allele, then you'd have 11, 10, 10, 00 as your possible genotypes.


This assumes that the gene in question is Mendelian. It also assumes that the gene has only two alleles.

The gene for ABO blood type has over 20 alleles. Most of those express themselves similarly, so if we simplify them to just 3 alleles A, B and O, that's still one more allele than you can represent with a simple RECESSIVE/DOMINANT bipartition.

Even if the gene only had 2 alleles, that doesn't necessarily mean that one of them will be dominant, and the other will be recessive. Sometimes both alleles will express themselves. Sometimes the expression will be a mix of how the alleles normally express themselves.
 
Mike Simmons
Master Rancher
Posts: 4920
74
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course, it's also possible that this is coursework of some sort, and the student is new to genomics, or programming, or both.  It's quite possible that an instructor gave the assignment in terms of 1 and 0 - and while we may feel there are better ways to represent this in the long run, 1 and 0 may be the best way for the problem as it has been described to the student.  I think it's possible to be a bit flexible on how we think this needs to be implemented, and let the student gradually figure out how to do it.  The implementation may evolve with understanding.
 
Marshal
Posts: 28263
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I agree, this thread is well into "The Perfect is the enemy of The Good" territory. I think it was stated in the original post that the student was new to programming, and I also agree that often it's best for students to work their way through exercises which try to reference interesting subjects, even if they may be over-simplified in terms of those subjects.
 
Junilu Lacar
Sheriff
Posts: 17652
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think students/learners come in at least two types. The first type is given a problem and just wants to find a solution and be done with it. The second type, however, is more interested in the problem solving process and its nuances.

But then again, maybe it's not so much a division as it is a progression. That is, as an absolute beginner you first focus on using what you know about the language to solve the problem in whatever way that works. As you gain proficiency with the language you start focusing on using it effectively to create a solution that's not only correct but also well-organized and coherent.

I agree, the student must be allowed to work things out for themselves. I think for the rest of us though, it's not so much about searching for perfection than it is about sharing what we each think could be a better approach and hoping it will help OP gain a deeper understanding that goes beyond syntax and logic. It's more about using the language as a way of expressing ideas. The problem is when what we share is too far away from where OP is to be able to successfully make that leap in understanding.

Good reminder to be mindful of OP and where they are in their learning journey.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic