Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!

Liutauras Vilda

Marshal
+ Follow
since Nov 12, 2014
Liutauras likes ...
BSD
software developer, moderator at coderanch, a father, husband and nintendo switch owner
London, United Kingdom
Cows and Likes
Cows
Total received
415
In last 30 days
4
Total given
1246
Likes
Total received
1246
Received in last 30 days
16
Total given
1126
Given in last 30 days
19
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Liutauras Vilda

First, pie slices to those who haven't got yet!!!

Some interesting points floating around, which in turn already allowed me to see some deficiencies with my current design. I need to absorb/experiment with each of these first.

But even now, I already can say a big thanks for your time and constructive criticism - I'll get back to each of you (salvin, Piet, Sresh), either late night today or other day once manage to spend some time on it.
5 days ago
In case somebody reads, one of my colleague here, Stephan, raised some concerns (behind the hood, within GitHub platform) regarding the topology, where I mixed up two different contexts Location and Direction into one - Location, and as a result represented directions where to move in order to find neighbours by reusing Location class (and that is bad), which actually represents an absolute path within a world map. So separated these lately and now there are Location and Direction (appear as an inner enum as it is needed just there for the moment).

Another point we discussed that I have an enum Cell which implements (/-ed actually) Mutable interface. And there he had a point. Enum is an immutable from Java's stand point, and to implement Mutable interface was a bit odd, even though the ideas underneath didn't clash much as simply two different domains interfered Java's (immutable enum) and automaton game (where cell mutates). As a result I renamed Mutable idea within the domain entirely, so it became:

Mutable -> Regenerable
Mutable.mutate() -> Regenerable.regenerate()
MutationRules -> RegenerationRules


And these make much more sense now. Thanks to him.

However, we still got an argument whether to represent Cell as an enum is a good idea. Maybe to have Cell as a regular class with an inner enum State ALIVE, ETC... would be better. I must say I had implemented that 2 days ago - well, more experiments to come.

It is very interesting little project to work on.
1 week ago

salvin francis wrote:I ran that program and it just printed a huge log of dots and zeros !!!
Even a simple JFrame with a single textarea would be great.


Yet again, first of all, thanks for reviewing it.

Yeah. Agree, it isn't user friendly and much interactive yet. But I have created for myself an enhancement item, so at some point will get it done.

However, at this stage my main goal was to come up with a design so it would be simple to understand, easy enough extend and very importantly to test. Tried to keep separate pieces responsible as much as their need to be responsible for, so changing something I wouldn't need to rewrite tests from scratch and similar. Interesting, but initially that was exactly my experience. Started with semi TDD, thought came up with a fairly nice approach, however, trapped to a situation, that I was not able to test everything without exposing objects internals as for instance Location class was relying on World's internal data structure to count alive neighbours around, and I did want to have minimum getters, minimum mutation... etc. So most of the time such figuring out design, but I'll have time for GUI, just my designer's skills aren't anywhere great.

salvin francis wrote:I am glad to see that your glider "wraps-around" the world.


Yep, since all action happens on an infinite grid, I was looking for the way to put this concept in place.

Thanks for comments.

salvin francis wrote:minor suggestions: Maybe World.SIZE could have an access modifier (probably public) ?


Nah Stephan some time ago suggested, and once again re-read Effective Java by Joshua Bloch, so basically I give visibility as much as it is needed and no more. On that point of view, I'd prefer that even interfaces would provide an ability to implement package-private methods, as sometimes (and I faced this situation too), I exposed method (meaning had to make public) without real need of that, i.e. Cell.mutate() is public, while perfectly could work with package-private visibility.
1 week ago

Jeanne Boyarsky wrote:In World, the indentation of this code misleads about what it does. Since the two forEach() statements are aligned, they imply that they are operating on the same stream.


First - thankful for a review and comments.

Agreed. Indentation was misleading. With streams kind of can get messy when always aligning by the dot ".". I simply now just let IDE to format for me based on by default pre-configured its rules.

Jeanne Boyarsky wrote:More importantly, calling map.put() in a forEach isn't good practice. Is there any reason you can't use a collector which would dispense with the inner forEach() entirely.


That's a good one! I was so concentrated on design, so got less than optimum at other points. Initially I simply had 2 habitual loops, so later decided to replace with forEach, hence got horrible blocks. Just refactored to use collectors you suggested in empty(); nextGeneration(); methods, indeed much better as it hides internals how data structure gets populated. However, a bit struggled until remembered how to do it with specific Map's implementation.

Jeanne Boyarsky wrote:I'm not a fan of the default method in Mutate. It feels like a hack since it isn't used for legacy code.


Well. I was researching about default before attempted to use it. To my disappointment, since Java moving towards modernising herself, I don't understand why default is so implied to be used only for legacy code. It is such a nice feature to have in my opinion (makes even slimmer gap between interface vs abstract class) and it fitted perfectly to my idea. Upon hypothetical requirements change mutable(s), i.e. Monster just need to implement that interface without providing any extras; and define their mutation rules. I'm not up (convinced yet) for removing it and implementing this method in the very same way in each and every concrete Mutable implementation.

Thanks for the comments once again!
1 week ago

Junilu Lacar wrote:If I had a collection of Book objects, would bookList.toArray(Book[]::new) be easier to read than bookList.toArray(new Book[0])?


With no doubts. new Book[0] is confusing as hell to me, because it gives an impression that it will create a 0 length array, and since we know arrays can't expand, it gives a feeling while Book[]::new suggests me that it will create an array of the needed size whatever that size might be, which in fact I don't need to know. That's how my brains interpret that.
1 week ago
Hello Ranchers,

For a long time I was fascinated about this project, but never attempted to implement it myself. That's changed.
So decided to create a personal construction site and work at it to practice and experiment with various design decisions implementing this cellular automaton.

For the past 3-4 days I wrote and re-wrote.. this project countless number of times (small portion of commits history recorded).
The version I have currently is something I think I could try to justify why I have it like that, and to what angle it has flexibility to offer so I chose to implement it that way.

However, do extra pairs of eyes see some illogical design decisions, or have tips what to think about how this could be improved further to avoid some potential limitations I could face when some hypothetical requirements change?

Don't get fooled by the width of the project (only very few source files), but it really taught me many lessons already, and I believe it will again.

From the very first versions I came up with, this recent version I think got shorter twice, I think it has more flexible design, it was way easier to test and achieve good enough test coverage. I'm currently at a stage when I need some subtle tips to move on further refinements (or.. fixes).

Please find project implementation at my GitHub area. For those who don't know the mentioned project, please read the description on Wikipedia.

Thanks.
1 week ago
Software craftsmanship events worth knowing, attending...

(sorted by the 'when' in an ascending order)
NameWhenWhereAbout
Hackathon~Mid of October (lasts 1-2 day(s))Physical attendance. Facilitated all around the world.A design sprint-like event in which computer programmers and others involved in software development, including graphic designers, interface designers, project managers, and others, often including subject-matter-experts, collaborate intensively on software projects.
Global Day of Coderetreat~Mid of November (lasts 1 day)Physical attendance. Facilitated all around the world.Intensive practice event, focusing on the fundamentals of software development and design.
Advent of Code~1st Dec - ~25th Dec (25 days long)Online attendance.Fun series of small programming puzzles for a variety of skill levels.
1 week ago
And modulus really help you to extract digits.

Think how dividing and using modulus operator you can extract individual digits. Brute force way to understand is to get calculator and play a bit (with some pretty predictable numbers to use for division, modulus) and see what you get.
1 week ago

jon ninpoja wrote:1234567890 % 10000
...
7890 it gave me the last four digits

but why is that?


jon, it is really easy to understand, you just need some primitive (might even dumb) example. Ignore what these mathematicians mumble around (just kidding), nobody understands them apart themselves

Imagine you have 10 apples. So what is the remainder 10 % 3...

So you simply do:
10 - 3 = 7
7 - 3 = 4
4 - 3 = 1
1 - 3 = alert, insufficient fonds. You have only 1 left.

So that 1 is the remainder. How it is implemented internally - not our business (probably differently than I described), but that certainly should help to understand what the remainder is.

Is any clearer now how you got 7890? (1234567890 % 10000)
1234567890 - 10000 = ...
... - 10000 = ...
7890 - 10000 = alert, insuf... Déjà vu
1 week ago

Carey Brown wrote:I haven't looked at all the code, but this is a mistake:
'|' is bit-wise OR and '||' is logical OR. Unless you are doing bit manipulation use logical OR
'&' is bit-wise AND and '&&' is logical AND. Use the logical AND.


Well, in more cases than not, it wouldn't cause code to misbehave, so that's not really a mistake, but more of unappropriate use in my opinion (not in all scenarios, though).

M. Gumblert wrote:hishand == "p"


This one is a mistake.
1 week ago

Micheal Bush wrote:Can you solve it??


I'm sure he can, anyway, that is your task for this very exercise. That is a part of learning process, I'm sure you do understand that. If you'd do as he suggested, probably you'd have it solved by now.

If you have been told an exact answer or provided with complete solution - you wouldn't have learned anything. The sooner you'll understand that, the easier is going to be in a future. You need to try to crack down the problems yourself, hints are fine though, we all sometimes need hints.
1 week ago

Maurizio Gasparro wrote:Junilu, your explaination about naming the fields or variables and the DRY principle it's veru useful for me because I'm a novice, so I need to know these things.


Not only novices need to be told these type of principles. It is ongoing process. Experienced and well experienced programmers also need to be trained in the same way, even though they know them. Similarly as sportsmen. All of them know their stuff, how to compete, even win, but they do have trainers who help them to refine their techniques so they can aim to be champions, and most importantly - need to be able to keep that level, and presumably grow - that is what coaches do, and this is in fact who Junilu is. So expect to see, hear and learn these type of principles constantly during your career as a programmer.
1 week ago
Congratulations on passing and passing with a great score.

Thanks for offering help... and welcome to the Ranch
I'm a bit disappointed that @OP is satisfied with such his approach solving this exercise.

I was studying myself and I know that having everything so chaotic leads nowhere. Better code organization is expected right from the 1st day of Introduction to Programming course. Meaning no prior experience is needed, but better code organization *is* expected. And that is not because somebody requires like that, that is because *that way* is much easier to solve problems.

1. All the comments you have aren't useful. And in some places - misleading. An example:

So what we see here. My guess is that OP's comments referring to the preceding lines. However, if you look closely, this comment is nonsense. I'll leave for OP to figure out what is wrong there.

2. Very first line says Averages5.java, yet the class declaration says it is Averages7. That shows how such comments go out of date in a blink of an eye. So better not to have such comments which say nothing and usually say wrong.

3. Snippet below:
@OP You don't need all these && operators. Think how you could simplify this code. i.e.:

4. Did you learn methods yet? Anyway, since you already using them, i.e.: main(), I'd suggest start organizing your program into methods, where each method does one thing and one thing only. i.e.:

Every little detail is important. You need to take control of your code and don't let the chaotic code ruin your project.
1 week ago
Pass the test? Add your name to the wall, partner.

OCMJEA Wall of Fame [order by Date]
VersionNameFinal Exam DatePart 1 ScoreAssignment ScoreStoryAssignmentWhat's NextCountry
JEE6Nataraj BasappaSeptember 26, 201873%152/160https://www.natarajmb.com/2018/09/journey-to-ocmjea/Quick Computer-UK
JEE6Mustapha SENHAJIFebruary 03, 201873%142/160-Retire EarlyAWS Solutions ArchitectMorocco
JEE6Gautam DebDecember 15, 201776%156/160-Retire Early-India
JEE6Ernest BarrosoNovember 02, 201778%131/160Two months on the 3 stepsGemstone InternationalSpring Professional CertificationVenezuela
JEE6Francesco FabiOctober 09, 201771%148/160-Team DoctorTOGAFItaly
JEE6Om Narayan PandeyJune 26, 201780%156/160-Dream Car-India
JEE6Samrat RoyMay 24, 201783%155/160https://coderanch.com/t/680789/certification/OCM-JEA-storyGemstone International-India
JEE6Sanjay GarothayaMay 01, 201780%151/160-Team Doctor-USA
JEE6Amine Ouali AlamiApril 02, 201778%156/160-Utility international-Morocco
JEE5Rajesh NarayananMar 17, 201792%143/160-Team Doctor-India
JEE6L. WitkowskiMar 1, 201771%140/160-Retire Early-Poland
JEE6Rajesh Kumar SrivastavaJan 24, 201773%139/160-Utility InternationalExpertise in Machine Learning & AIIndia
JEE6Raghavendra DesojuJan 23, 201783%149/160-Quick ComputerAWS Solutions ArchitectUSA
JEE6Carlo CangemiDecember 23, 201688%144/160-Dream Car-Italy
JEE6K. TsangDec 2, 201671%-(JEE5 upgrade)---Hong Kong
JEE6Sergio Navarro GarzaMay 28, 201683%149/160-Utility InternationalTOGAFSpain
JEE6Caio BessaMay 19, 201671%143/160-Retire EarlyIELTSBrazil
JEE6Mithun M SMay 05, 201678%141/160StoryWireless Phone CompanyTOGAFIndia
JEE6Yogaraj KhanalMarch 23, 201671%138/160-Quick ComputerOSCPNepal
JEE6Angelo VerdicchioFeb 05, 201683%148/160-Factory HomesImprove design & architecture skillsItaly
JEE5Sourav BiswasFeb 17, 201693%144/160-Retire EarlyImprove design & architecture skillsAustralia/India
JEE6Siddhesh JogJan 27, 201676%146/160-Wireless Phone CompanyImprove design & architecture skillsIndia
JEE6Mika KilpeläinenDec 7, 2015PP-Gusher OilHTML+CSSFinland
JEE6Vijay SNNov 28, 201586%145/160 90%-Wireless Phone CompanyImprove Architect SkillsIndia
JEE6Efthymia ArmanidiJune 2, 201571%149/160 93%-Team DoctorITILGreece
JEE6Rodrigo CayresOct 19, 201581%153/160 96%-Big Smokes Cigar ShopOCEJEE6JSFD (JSF)Brasil
JEE6Vijaya RaghavaSept 26, 201581%143/160-Team DoctorPMP, HadoopIndia
JEE6Claudia ArévaloJun 25, 201588%153/160StoryFactory HomesTOGAFColombia
JEE6Heliton Rodrigues Aranha FilhoApr-30-201573%NA (JEE5 Upgrade)http://www.coderanch.com/t/650230/java-Architect-OCMJEA/certification/Certified-OCMJEA-finallyNA (JEE5 Upgrade)TBDBrazil
JEE5K. TsangMar 4, 201589%144/160part1 part2/3Quick Computer-Hong Kong
JEE6Mike DegteariovMar-31-201578%151/160-Team DoctorHadoopCanada
JEE6Bora SevenMar-12-201571%140/160StoryBig Smokes Cigar ShopTOGAF9Turkey
JEE5Heliton Rodrigues Aranha FilhoOct-18-201471%141/160http://www.coderanch.com/t/650230/java-Architect-OCMJEA/certification/Certified-OCMJEA-finallyFactory HomesTBDBrazil
JEE6Rahul SharesthSep-19-201483%141/160-DreamcarTBDIndia
JEE6Mahavir SinghAug-10-201471%140/160-Utility InternationalImprove Architect skillsIndia
JEE5Anuj SethiJul-1-201490%141/160-Team DoctorImprove architect skillsIRE
JEE6Raffaele SangiovanniMay-1-201480%153/160-Wireless Phone CompanyScrumITA
JEE5Pothiraj MarichamyMar-1-201495%P-Team DoctorTBDUSA
JEE5Uma Monday2014-02-2895%145/160-Gemstones InternationalTOGAF9USA
JEE5Sirish K Somanchi2013-06-1178%152/160-Team DoctorTOGAF9India
JEE5Marco Bresciani2013-01-3164%134/160-Wireless Phone CompanyRuby and RoRItaly
JEE5Subrahmanyam BV2012-12-1589%152/160-Team Doctor-India
JEE5Sachin Dixit08-Dec-201278%144/160-Team DoctorPMPIndia
JEE5Diego Lins de Freitas11-October-201285%140/160-Quick ComputerIEEE - CSDPBrazil
JEE5Juan Gonzalez del Pino11-October-2012PPStoryGusher OilNot sureSpain
JEE5Chandra S Billanuka15-July-2012PP-Wireless Phone CompanyTBDUSA
JEE5Chennakrishna R Gottam29-July-2012PP-Gusher OilPEGAUSA
JEE5Srinivasulu Kopparapo06-July-2012P71%"Here"Gusher OilJava Enterprise Edition Certified MasterUSA
JEE5Sudha Sundar18-Feb-2012P153/160HereGusher OilOracle IT Implementation Specialist, PMPUSA
JEE5Neeraj Javiya21-Jan-2012PPHereTeam DoctorTBDUSA
JEE5Mahesh R. Desai12-Dec-2011PP-NA (JEE5 Upgrade)Oracle Linux Fundamentals, PMPCalifornia, USA
JEE5Sada Kurapati22-Dec-201195%146/160Part I StoryGusher OilTOGAFUSA
JEE5Mahesh R. Desai12-Dec-2011PP-NA (JEE5 Upgrade)Oracle Linux Fundamentals, PMPCalifornia, USA
JEE5Eric Manuguerra04-Oct-201185P-Factory HomesTBDFrance
JEE5Mayur Bodkhe27-Sep-2011P143/160-Wireless Phone CompanyTBDUK
JEE5Sankha S Pathak27-Aug-2011P155/160-Wireless Phone CompanyTOGAFINDIA
JEE5Vignesh Murali Natarajan21-Aug-2011100P-Big Smokes Cigar ShopPMP?India
JEE5M. A. Riveros T.21-Aug-2011PP-DreamcarTBDColombia
JEE5Jari Timonen29-JUN-2011PPPart1Factory Homes-Finland
JEE5Roxana Crisan17-Jun-201193P-DreamcarTBDRomania
JEE5Tan Chin Sheng12-Jun-201196P-Factory HomesTOGAF9Singapore
JEE5Ashutosh Sharma29-Mar-2011PPHereBig Smokes Cigar ShopTOGAF9USA
JEE5Martin Zisler19-Jan-2011PP-Gusher OilJEE6 WebservicesSwitzerland
JEE5Wolfgang Unger21-Dec-2010PP-Big SmokesHoliday in BrazilGermany
JEE5Jeanne Boyarsky17-Nov-201087PHereFactory HomesTBDUSA
JEE5Rupesh Kumar17-Nov-201082P-Dream CarTBDUSA
JEE5Sylvain Duchesne12-Nov-2010PP-Dream CarSCEA for Java EE6 - UpgradeCanada
JEE 5Ravi Iyer21-Oct-2010PPStoryFactory Homes-India
JEE5Kuppusamy Venkatasubramanian19-Jul-201085PHereDream CarTBDSingapore
JEE5Varun Chopra03-Mar-201096PStoryFactory HomesTBD-
JEE5Jose Luis Iturbide24-Apr-200971PStoryFactory HomesSpring & AndroidMexico
J2EEGabriel Belingueres30-Dec-20088591-Fly By Night--
J2EEStefan Meier29-Dec-20088977StoryFly By NightSCEA5 Upgrade-
J2EEMahesh R. Desai12-Dec-20088189StoryFly By NightSCEA for Java EE6 - UpgradeCalifornia, USA
J2EEPaul Michael5-Nov-20089177StoryFly By NightFlex or .Net-
J2EEAbhinav Srivastava6-jul-20088995hereFly By Night --
J2EEAshish Sarin15-Aug-20087092hereFly By NightTOGAF-
J2EEPatrick Williams14-Nov-20078587StoryFly By NightSCJD & Upgrades-


Other Java Certification Wall of Fames

SCJA Wall of FameSCJP Wall of FameSCJD Wall of FameSCBCD Wall of Fame
1 week ago