• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 18:26
CEST 00:26
KST 07:26
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Serral wins HomeStory Cup 2914Serral wins Maestros of the Game 243ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12
Community News
Balance hotfix patch 5.0.16b (July 16)34Reynor: GSL Loss Wasn't About Preparation Format16[IPSL] Spring 2026 Grand Finals - This Weekend!5Weekly Cups (July 6 - 12): Protoss strike back12BSL Season 22 Full Overview & Conclusion8
StarCraft 2
General
Balance hotfix patch 5.0.16b (July 16) [D] Wireframe Casting Removed Clem: "I don't have that much hope in Blizzard" Reynor: GSL Loss Wasn't About Preparation Format Is the larve respawn broken?
Tourneys
Master Swan Open (Global Bronze-Master 2) WardiTV Summer Cup 2026 GSL CK #5 Race War RSL Revival: Season 6 - Qualifiers and Main Event HomeStory Cup 29
Strategy
[G] Having the right mentality to improve
Custom Maps
New Map Maker - Looking for Advice - Love or Hate Work In Progress Melee Maps [D]RTS in all its shapes and glory <3
External Content
The PondCast: SC2 News & Results Mutation # 534 Burning Evacuation Mutation # 533 Die Together Mutation # 532 Nuclear Family
Brood War
General
Etiquete rules in Asl? BW General Discussion Recent recommended BW games Recommended FPV games (post-KeSPA) Pros Debate: Zerg Unfairly Nerfed? (ASL S22 map)
Tourneys
Escore Tournament - Season 3 Small VOD Thread 2.0 [IPSL] Spring 2026 Grand Finals - This Weekend! [Megathread] Daily Proleagues
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Creating a full chart of Zerg builds Relatively freeroll strategies
Other Games
General Games
General RTS Discussion Thread Path of Exile Nintendo Switch Thread Beyond All Reason Stormgate/Frost Giant Megathread
Dota 2
Looking for a Dota Mentor Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread The Games Industry And ATVI Russo-Ukrainian War Thread UK Politics Mega-thread YouTube Thread
Fan Clubs
The IdrA Fan Club The HerO Fan Club!
Media & Entertainment
Movie Discussion! Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Series you have seen recently...
Sports
2024 - 2026 Football Thread MLB/Baseball 2023 McBoner: A hockey love story Tennis[sport] Formula 1 Discussion
World Cup 2022
Tech Support
Simple Questions Simple Answers FPS when play League Of Legend on laptop How to clean a TTe Thermaltake keyboard?
TL Community
Northern Ireland Global Starcraft The Automated Ban List
Blogs
Poker (part 2)
Nebuchad
The Experiences We Want and …
TrAiDoS
An Exploration of th…
waywardstrategy
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Evil Gacha Games and the…
ffswowsucks
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 5346 users

The Big Programming Thread - Page 416

Forum Index > General Forum
Post a Reply
Prev 1 414 415 416 417 418 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-12-29 22:23:39
December 29 2013 22:19 GMT
#8301
On December 30 2013 06:12 teamamerica wrote:
Anyone have advice on good books/pointers on designing stuff? Writing in object orientated languages, one thing I struggle with is how to design my classes. Things like: should this be static function or instance. Should this be in constructor or passed into function. Should I pass an object and act on a copy, or mutate the object that was passed in.

Also the same question about good references for how to set up relational database schema? e.g. surrogate keys vs natural keys.

One thing I was just working on was...
+ Show Spoiler +

One thing I just worked on had records which had either a "rast" or "patric" type annotation. Each annotation type provided different information i.e. different columns. So for each record I stored "annotation type" as an "enum", and had 2 tables {rast, patric} annotation. My question in this case is twofold:
1) better to have split it into 2 tables or used one larger table (annotation) and nulled out columns as appropriate
2) better to use enum to describe annotation type or a values table (e.g. annotation type column => annotation_types table => "rast" | "patric".
3) and this might be mysql specific. Some of the columns in the annotation table are rather large - 500char+. When to use varchar(500) or "TEXT". Say the column "length" is 500+ characters. I've seen before comments that TEXT and BLOB columns can make table operations that don't even effect these columns really expensive. Should I have stored "length" in a seperate table, and had a lookup table from the main record to it?

The data seemed pretty relational but it feels weird to columns with so much text into a database.


I'm looking through Effective Java which I find pretty interesting, and it kind of covers questions of the second instance, but not really questions of the first instance.


Object Oriented* not Object Orientated

I haven't seen any Java books that are useful.

I've read a ton of books on OO and this is still my favorite

http://www.amazon.com/Object-Design-Roles-Responsibilities-Collaborations/dp/0201379430

Generally avoid using class variables and methods if you can. The less you rely on state the better. Basically your program is a system of collaborating objects that work together to solve a problem. Think of it like an organisation, you have different people specialising in different tasks all working together.

Just incase you missed it, I just gave a guy a refactored tictactoe example with heavy object decomposition and functional decomposition. That's basically all you need to master for the first year, once you have that down you stop wasting time thinking about any of this stuff and the rest comes easy.

https://github.com/DanielShuey/Java-TicTacToe-Example/tree/master/src/tictactoe
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-12-29 22:55:10
December 29 2013 22:54 GMT
#8302
^ the book's title reminds me of CRC (Class-responsibility-collaboration): wikipedia. Is that what it teaches?
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-12-30 00:37:55
December 30 2013 00:34 GMT
#8303
On December 30 2013 07:54 darkness wrote:
^ the book's title reminds me of CRC (Class-responsibility-collaboration): wikipedia. Is that what it teaches?


Class Responsibility Collaboration is probably an inspiration for Responsibility Driven Design.

CRC cards are really unnecessary though, I've found having brainstorming sessions for design to be a complete wank. 99% of the time you end up just wanting to completely change the design during implementation anyway.

Also the use of CRC cards in extreme programming is usually for writing stories rather than design, extreme programming spends basically 0 time on design, I think that wiki entry is a tad misguided.

Although CRC is probably a really broad and undefined term, where as RDD is a bit more defined and structured. You don't need to spend time brainstorming with RDD either, its just a mindset that you have, at least for me anyways.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
bangsholt
Profile Joined June 2011
Denmark138 Posts
December 30 2013 01:46 GMT
#8304
On December 30 2013 05:30 wozzot wrote:
Programming newbie, making a Rubik's Cube solver, feeling really dumb right now.

I think I can manage to get the cube structure, the transformation subroutine, and solver algorithm going, but I don't know how the hell I should store the cubelet data, the data that tells me that the TL corner of the top face is connected to the TL of the left face and TR of the back face so that I can rotate them together and so on.

Right now, I'm using this and using split to retrieve the face + side/corner pairs:


my cubelets[6][9];
{
cubelets[0][0] = ( ["1 0", "4 2"] );
cubelets[0][1] = "4 1";
cubelets[0][2] = ( ["4 0", "3 2"] );
cubelets[0][3] = "1 1";
cubelets[0][5] = "3 1";
cubelets[0][6] = ( ["1 2", "2 0"] );
cubelets[0][7] = "2 1";
cubelets[0][8] = ( ["2 2", "3 0"] );

cubelets[1][0] = ( ["0 0", "4 2"] );
cubelets[1][1] = "0 3";
cubelets[1][2] = ( ["0 6", "2 0"] );
cubelets[1][3] = "4 5";
cubelets[1][5] = "2 3";
cubelets[1][6] = ( ["4 8", "5 6"] );
cubelets[1][7] = "5 3";
cubelets[1][8] = ( ["2 6", "5 0"] );

cubelets[2][0] = ( ["0 6", "1 2"] );
cubelets[2][1] = "0 7";
cubelets[2][2] = ( ["0 8", "3 0"] );
cubelets[2][3] = "1 5";
cubelets[2][5] = "3 3";
cubelets[2][6] = ( ["1 8", "5 0"] );
cubelets[2][7] = "5 1";
cubelets[2][8] = ( ["3 6", "5 2"] );

...

But I'm pretty sure that this is either non-optimal or I might be approaching this problem completely the wrong way. Am I doing something wrong? Any advice on how to go about doing this?

e: Only on Layer 1 and it's already about 250 lines of code, I'm definitely screwing something up but may as well keep on going


So if I understand it correctly, the first index in your array is an arbitrary side number of the cube and the second index is the squares of the side?

First of all, you could encode the current system of sides and squares into an integer - I'm thinking something like 28 - this would allow you to do a modulus operation to get the side and square. (Example would be: int side = encode / 10, int square = encode % 10)

Then you can save a list of those in a list which holds all the corners of the cube - so basically you would end up with a structure that's like this

List<List<Integer>> corners;

Then you can with ease do a simple for-loop over it and figure out which squares are connected to each other. This of course takes some time to iterate, but for now the important thing is to get it working, then you can start optimizing afterwards
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
Last Edited: 2013-12-30 14:56:58
December 30 2013 14:52 GMT
#8305
In PHP things are all set up with lamp/wamp framework and if you want to make a login page you can do it with just a php script and an html form page that passes directly to that php file.

How do you make a login page with c# using the microsoft mvc framework? It's just so confusing.

I'm reading this stuff and they just give you buttons to click. There's so many layers of abstraction that I don't really see what's going on anymore. How does the html form page interact with the back end c# code to authenticate a user?

http://msdn.microsoft.com/en-us/library/879kf95c(v=vs.100).aspx

Can I make a login page that doesn't use membership?
How does the c# aspx file link to the back end mssql database?

Nvm, fuck microsoft, there's a tutorial here:
http://www.daniweb.com/web-development/aspnet/threads/6028/simple-asp.net-login-page-using-vb.net

I can try this.
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
December 30 2013 14:55 GMT
#8306
On December 30 2013 23:52 obesechicken13 wrote:
In PHP things are all set up with lamp/wamp framework and if you want to make a login page you can do it with just a php script and an html form page that passes directly to that php file.

How do you make a login page with c# using the microsoft mvc framework? It's just so confusing.

I'm reading this stuff and they just give you buttons to click. There's so many layers of abstraction that I don't really see what's going on anymore. How does the html form page interact with the back end c# code to authenticate a user?

http://msdn.microsoft.com/en-us/library/879kf95c(v=vs.100).aspx

Can I make a login page that doesn't use membership?

You can make your own login system just fine, it basically works the same as in PHP. A cshtml page with the login form, and a controller to handle the authentication etc. The problem, of course, is to make it secure and good, which is what membership (to some extent) fixes for you. It's quite a complex thing, which is why there are so many layers of abstraction.

(If you want to learn more about the abstractions, try writing your own membership provider, I'm sure there are decent tutorials for it).
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
Last Edited: 2013-12-30 15:00:18
December 30 2013 14:58 GMT
#8307
On December 30 2013 23:55 Tobberoth wrote:
Show nested quote +
On December 30 2013 23:52 obesechicken13 wrote:
In PHP things are all set up with lamp/wamp framework and if you want to make a login page you can do it with just a php script and an html form page that passes directly to that php file.

How do you make a login page with c# using the microsoft mvc framework? It's just so confusing.

I'm reading this stuff and they just give you buttons to click. There's so many layers of abstraction that I don't really see what's going on anymore. How does the html form page interact with the back end c# code to authenticate a user?

http://msdn.microsoft.com/en-us/library/879kf95c(v=vs.100).aspx

Can I make a login page that doesn't use membership?

You can make your own login system just fine, it basically works the same as in PHP. A cshtml page with the login form, and a controller to handle the authentication etc. The problem, of course, is to make it secure and good, which is what membership (to some extent) fixes for you. It's quite a complex thing, which is why there are so many layers of abstraction.

(If you want to learn more about the abstractions, try writing your own membership provider, I'm sure there are decent tutorials for it).

Ok that makes sense. Do the membership providers still use your mssql database? If so which tables do they use?

edit: nvm, it looks like you can specify a sql data store, but I still have to figure out how to set that up. Last time I tried to set up memberships I ran into error messages for a day.
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
Requizen
Profile Blog Joined March 2011
United States33802 Posts
December 30 2013 18:00 GMT
#8308
Anyone have any experience implementing the Twitch API or Javascript commands?
It's your boy Guzma!
Housemd
Profile Joined March 2010
United States1407 Posts
December 30 2013 19:33 GMT
#8309
I'm so lost right now so if someone could help me a little.

So the problem states that I have to print out the numbers from 1 to 100. Simple enough. But then it states that I need to print out their multiples on the same line up until the multiples are less than or equal to 500. For example, on line 99, it should print:

99, 198, 297, 396, 495

I also have to use a while loop inside a for loop. I got the simple part down, which is printing out the numbers. I have: for
(int i = 1; i <= 100; i++){
System.out.println(i);
}

I've tried numerous ways to get the answer. For example, one attempt was to introduce a new variable x, increment it by one and state (while x <=500), print out i. Does not work.

Not looking for the answer, just some help on introducing the while loop.

Should I initialize a new variable?
How would I print out the multiples?
Fantasy is a beast
Cyx.
Profile Joined November 2010
Canada806 Posts
Last Edited: 2013-12-30 19:47:30
December 30 2013 19:46 GMT
#8310
On December 31 2013 04:33 Housemd wrote:

I also have to use a while loop inside a for loop. I got the simple part down, which is printing out the numbers. I have: for
(int i = 1; i <= 100; i++){
System.out.println(i);
}

I've tried numerous ways to get the answer. For example, one attempt was to introduce a new variable x, increment it by one and state (while x <=500), print out i. Does not work.

Not looking for the answer, just some help on introducing the while loop.

Should I initialize a new variable?
How would I print out the multiples?


Yeah, you should probably be using a new variable ^^ Your approach seems basically right so far - the only thing you're doing wrong basically is incrementing by one inside your new while loop instead of just increasing it by i.

introduce a new variable x, state (while x <=500), print out x and increment it by i.
Housemd
Profile Joined March 2010
United States1407 Posts
Last Edited: 2013-12-30 20:33:27
December 30 2013 20:28 GMT
#8311
On December 31 2013 04:46 Cyx. wrote:
Show nested quote +
On December 31 2013 04:33 Housemd wrote:

I also have to use a while loop inside a for loop. I got the simple part down, which is printing out the numbers. I have: for
(int i = 1; i <= 100; i++){
System.out.println(i);
}

I've tried numerous ways to get the answer. For example, one attempt was to introduce a new variable x, increment it by one and state (while x <=500), print out i. Does not work.

Not looking for the answer, just some help on introducing the while loop.

Should I initialize a new variable?
How would I print out the multiples?


Yeah, you should probably be using a new variable ^^ Your approach seems basically right so far - the only thing you're doing wrong basically is incrementing by one inside your new while loop instead of just increasing it by i.

Show nested quote +
introduce a new variable x, state (while x <=500), print out x and increment it by i.


Thanks for the help. Just a couple of questions.
int x = 0;
for (int i = 1; i <= 100; i++){
while (x <= 500)
System.out.println(x+=i);

Now, when I print x, it gives me the numbers 1-501. I'm assuming there is something wrong with my while loop?
Fantasy is a beast
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
December 30 2013 20:51 GMT
#8312
On December 31 2013 05:28 Housemd wrote:
Show nested quote +
On December 31 2013 04:46 Cyx. wrote:
On December 31 2013 04:33 Housemd wrote:

I also have to use a while loop inside a for loop. I got the simple part down, which is printing out the numbers. I have: for
(int i = 1; i <= 100; i++){
System.out.println(i);
}

I've tried numerous ways to get the answer. For example, one attempt was to introduce a new variable x, increment it by one and state (while x <=500), print out i. Does not work.

Not looking for the answer, just some help on introducing the while loop.

Should I initialize a new variable?
How would I print out the multiples?


Yeah, you should probably be using a new variable ^^ Your approach seems basically right so far - the only thing you're doing wrong basically is incrementing by one inside your new while loop instead of just increasing it by i.

introduce a new variable x, state (while x <=500), print out x and increment it by i.


Thanks for the help. Just a couple of questions.
int x = 0;
for (int i = 1; i <= 100; i++){
while (x <= 500)
System.out.println(x+=i);

Now, when I print x, it gives me the numbers 1-501. I'm assuming there is something wrong with my while loop?


Well, just consider what happens when x is 500.

Also, consider what happens when i increments to 2...what is x's value?
Average means I'm better than half of you.
scudst0rm
Profile Joined May 2010
Canada1149 Posts
December 30 2013 21:00 GMT
#8313
On December 31 2013 05:28 Housemd wrote:
Show nested quote +
On December 31 2013 04:46 Cyx. wrote:
On December 31 2013 04:33 Housemd wrote:

I also have to use a while loop inside a for loop. I got the simple part down, which is printing out the numbers. I have: for
(int i = 1; i <= 100; i++){
System.out.println(i);
}

I've tried numerous ways to get the answer. For example, one attempt was to introduce a new variable x, increment it by one and state (while x <=500), print out i. Does not work.

Not looking for the answer, just some help on introducing the while loop.

Should I initialize a new variable?
How would I print out the multiples?


Yeah, you should probably be using a new variable ^^ Your approach seems basically right so far - the only thing you're doing wrong basically is incrementing by one inside your new while loop instead of just increasing it by i.

introduce a new variable x, state (while x <=500), print out x and increment it by i.


Thanks for the help. Just a couple of questions.
int x = 0;
for (int i = 1; i <= 100; i++){
while (x <= 500)
System.out.println(x+=i);

Now, when I print x, it gives me the numbers 1-501. I'm assuming there is something wrong with my while loop?


You're making a pretty big assumption on what x+=i will return and your assumption is wrong.
You're like a one ranger army comin' at me...
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-12-30 22:06:33
December 30 2013 22:05 GMT
#8314
Is lazy initialization always good to use or is there a point of "overuse"? Example code:


private File theFile;
...
public File getFile() {
if (theFile == null) {
theFile = new File(PATH);
}
return theFile;
}
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
December 30 2013 23:06 GMT
#8315
No point in applying programming paradigms unless you actually have a use for them. In this case, do you actually care about the performance gains of whether you initialize the object at start-up versus run-time, or is the lazy initialization driven by an I/O or possibly a time-sensitive event? If no, then no point in applying it, same with all other patterns.
There is no one like you in the universe.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
December 30 2013 23:38 GMT
#8316
On December 31 2013 08:06 Blisse wrote:
No point in applying programming paradigms unless you actually have a use for them. In this case, do you actually care about the performance gains of whether you initialize the object at start-up versus run-time, or is the lazy initialization driven by an I/O or possibly a time-sensitive event? If no, then no point in applying it, same with all other patterns.

The classic "You'll never use it" anti-pattern. Focusing so hard to programming paradigms and design patterns that you spend more time planning code than writing it and therefor never getting any benefit.

Write code, refactor it later. Why lazy initialize something unless you know there's a definite benefit to doing so?
killa_robot
Profile Joined May 2010
Canada1884 Posts
Last Edited: 2013-12-31 01:27:44
December 31 2013 01:22 GMT
#8317
On December 31 2013 05:28 Housemd wrote:
Show nested quote +
On December 31 2013 04:46 Cyx. wrote:
On December 31 2013 04:33 Housemd wrote:

I also have to use a while loop inside a for loop. I got the simple part down, which is printing out the numbers. I have: for
(int i = 1; i <= 100; i++){
System.out.println(i);
}

I've tried numerous ways to get the answer. For example, one attempt was to introduce a new variable x, increment it by one and state (while x <=500), print out i. Does not work.

Not looking for the answer, just some help on introducing the while loop.

Should I initialize a new variable?
How would I print out the multiples?


Yeah, you should probably be using a new variable ^^ Your approach seems basically right so far - the only thing you're doing wrong basically is incrementing by one inside your new while loop instead of just increasing it by i.

introduce a new variable x, state (while x <=500), print out x and increment it by i.


Thanks for the help. Just a couple of questions.
int x = 0;
for (int i = 1; i <= 100; i++){
while (x <= 500)
System.out.println(x+=i);

Now, when I print x, it gives me the numbers 1-501. I'm assuming there is something wrong with my while loop?


Nope, it's doing exactly what you're telling it too

Once i = 2 (second time it goes through the outer loop), x is still <= 500, since you set it to 0 outside of the loops. If you want the while loop to run every time i increments, set x=0 within the for loop. You also may want to set x+=i before the println, then just print out x.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-12-31 09:13:55
December 31 2013 09:13 GMT
#8318
On December 31 2013 08:38 Tobberoth wrote:
Show nested quote +
On December 31 2013 08:06 Blisse wrote:
No point in applying programming paradigms unless you actually have a use for them. In this case, do you actually care about the performance gains of whether you initialize the object at start-up versus run-time, or is the lazy initialization driven by an I/O or possibly a time-sensitive event? If no, then no point in applying it, same with all other patterns.

The classic "You'll never use it" anti-pattern. Focusing so hard to programming paradigms and design patterns that you spend more time planning code than writing it and therefor never getting any benefit.

Write code, refactor it later. Why lazy initialize something unless you know there's a definite benefit to doing so?


I'm not sure how files are handled by OS especially when they're big. But if they take more memory because of their larger size, then I can see a benefit if lazy initialization is used in this case.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-12-31 09:36:36
December 31 2013 09:32 GMT
#8319
On December 31 2013 08:38 Tobberoth wrote:
Show nested quote +
On December 31 2013 08:06 Blisse wrote:
No point in applying programming paradigms unless you actually have a use for them. In this case, do you actually care about the performance gains of whether you initialize the object at start-up versus run-time, or is the lazy initialization driven by an I/O or possibly a time-sensitive event? If no, then no point in applying it, same with all other patterns.

The classic "You'll never use it" anti-pattern. Focusing so hard to programming paradigms and design patterns that you spend more time planning code than writing it and therefor never getting any benefit.

Write code, refactor it later. Why lazy initialize something unless you know there's a definite benefit to doing so?


On December 31 2013 08:06 Blisse wrote:
No point in applying programming paradigms unless you actually have a use for them. In this case, do you actually care about the performance gains of whether you initialize the object at start-up versus run-time, or is the lazy initialization driven by an I/O or possibly a time-sensitive event? If no, then no point in applying it, same with all other patterns.


Applying programming paradigms are extremely important, design patterns are kinda important.

Pre-optimisation and over-engineering however is a bad thing. Some companies use a "computer architect" to come up with an over-engineered UML design before implementing it, that certainly is really stupid.

His example is a classic case of pre-optimisation, not 'applying a design pattern'. It also has nothing to do with a programming paradigm.

You should never ever neglect learning programming paradigms. Mastering programming paradigms will speed up productivity and make sure your code is nice and clean. It basically allows you to write clean code without even having to think about it. People in this thread who need help on cleaning up their code are usually suffering from not knowing the paradigm enough.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2013-12-31 10:08:17
December 31 2013 09:43 GMT
#8320
He's not pre-optimizing anything though. He's asking a question about applying a design pattern. We're saying to be careful of over-using programming paradigms/patterns in cases where they're not necessarily useful. Part of learning a paradigm is to actually learn when they're actually useful, and part of learning paradigms in general is understanding when to use them and when not to, and being wary of overusing them, which is what he originally asked about.

Anyways, it worked, because now he's asking questions about what situations where applying the pattern would be relevant. I think I could have gone into it directly though without the side tangent against overuse. I may have misunderstood the question the first time.



On December 31 2013 18:13 darkness wrote:
Show nested quote +
On December 31 2013 08:38 Tobberoth wrote:
On December 31 2013 08:06 Blisse wrote:
No point in applying programming paradigms unless you actually have a use for them. In this case, do you actually care about the performance gains of whether you initialize the object at start-up versus run-time, or is the lazy initialization driven by an I/O or possibly a time-sensitive event? If no, then no point in applying it, same with all other patterns.

The classic "You'll never use it" anti-pattern. Focusing so hard to programming paradigms and design patterns that you spend more time planning code than writing it and therefor never getting any benefit.

Write code, refactor it later. Why lazy initialize something unless you know there's a definite benefit to doing so?


I'm not sure how files are handled by OS especially when they're big. But if they take more memory because of their larger size, then I can see a benefit if lazy initialization is used in this case.


Yes, you would see memory (maybe performance as you said) benefits because you're not holding a reference to the large File object.


But most of the time, that would never happen.

When working with files, the standard protocol is keeping the file path, and when you need to do work on it, open the file, do the work, then close the file object.

It is pretty bad practice to keep references to things like files. Mainly because you may forget to deallocate them and you'll have a memory leak, whereas `open, work, close` is very clear.



An example of lazy initialization:

Suppose you had an application that communicated with a server. Typically when the application starts up, you would setup most of your objects, and then begin communication. However, if the server communication is I/O driven, suppose, the user had to type in a password 1234 before anything would happen, then it may be nice to delay setting up until after the password is entered, because you don't necessarily need anything yet. And if the password is not entered or if the user quits, then you wouldn't have wasted time/resources setting up. If the password is entered, then you can now initialize your objects. Of course, this is a poorly engineered example, but hopefully you can see a use and a possible benefit.






On a side note, it is really weird to work coincidentally on 3 separate, dependant projects.

Project C (and in the future, D), are dependent on a common base B, which is dependent on another library, A, all of which I'm writing. Very strange. But it's entertaining being able to engineer all parts of the project and applying crazy design patterns all over the place because I'm bored.

Also, I saw a place in my code where a function had 8 lines of code and I remembered the argument a couple pages back here. Haha.
There is no one like you in the universe.
Prev 1 414 415 416 417 418 1032 Next
Please log in or register to reply.
Live Events Refresh
The PiG Daily
22:00
Best Games of SC
ByuN vs Clem
MaxPax vs TBD
Serral vs ByuN
GgMaChine vs Bunny
PiGStarcraft220
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 785
PiGStarcraft220
ViBE139
JuggernautJason137
CosmosSc2 69
StarCraft: Brood War
ZZZero.O 41
Dota 2
NeuroSwarm62
Super Smash Bros
hungrybox309
Mew2King133
Heroes of the Storm
Trikslyr56
Other Games
gofns12529
tarik_tv5822
Grubby2969
shahzam999
ToD236
Liquid`Hasu212
mouzStarbuck172
XaKoH 162
Livibee70
B2W.Neo46
Organizations
Other Games
gamesdonequick2066
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 16 non-featured ]
StarCraft 2
• Hupsaiya 58
• musti20045 29
• davetesta26
• RyuSc2 4
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota21358
Other Games
• Shiphtur841
Upcoming Events
Replay Cast
1h 34m
RSL Revival
10h 34m
Clem vs Lambo
Scarlett vs Cure
CranKy Ducklings
11h 34m
Epic.LAN
14h 34m
IPSL
17h 34m
Dragon vs Hawk
RSL Revival
1d 10h
Classic vs Trap
herO vs SHIN
Sparkling Tuna Cup
1d 11h
OSC
1d 14h
IPSL
1d 17h
Bonyth vs Ret
WardiTV Weekly
2 days
[ Show More ]
Monday Night Weeklies
2 days
PiGosaur Cup
4 days
The PondCast
4 days
Replay Cast
5 days
CrankTV Team League
5 days
Replay Cast
6 days
CrankTV Team League
6 days
Liquipedia Results

Completed

Proleague 2026-07-13
HSC XXIX
Eternal Conflict S2 E2

Ongoing

IPSL Spring 2026
Acropolis #4
YSL S3
CSL 2026 Summer (S21)
KCM Race Survival 2026 Season 3
Escore Tournament S3: W3
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026

Upcoming

ASL S22 SEASON OPEN Day 1
Escore Tournament S3: W4
ASL S22 SEASON OPEN Day 2
Escore Tournament S3: W5
CSLAN 4
Blizzard Classic Cup 2026
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
Light Tournament 2026
Eternal Conflict S2 Finale
Eternal Conflict S2 E3
Logitech G Connect 2026
StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Disclosure: This page contains affiliate marketing links that support TLnet.

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.