• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 07:08
CEST 13:08
KST 20:08
  • 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)17Reynor: 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
Reynor: GSL Loss Wasn't About Preparation Format Balance hotfix patch 5.0.16b (July 16) Is the larve respawn broken? 5.0.16 patch for SC2 goes live (8 worker start) BGE Stara Zagora to be held again in June 2025
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? Recommended FPV games (post-KeSPA) Pros Debate: Zerg Unfairly Nerfed? (ASL S22 map) BGH Auto Balance -> http://bghmmr.eu/ screpdb: new Starcraft reporting tool
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 Nintendo Switch Thread Path of Exile 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 Russo-Ukrainian War Thread UK Politics Mega-thread YouTube Thread Canadian Politics Mega-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
Gauntlet SC2: A Retrospectiv…
Ctone23
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 8330 users

The Big Programming Thread - Page 407

Forum Index > General Forum
Post a Reply
Prev 1 405 406 407 408 409 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.
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
Last Edited: 2013-12-08 09:29:34
December 08 2013 09:29 GMT
#8121
On December 08 2013 18:05 ambikalx wrote:
Hey guys! It's been a while since I've hit this thread up. This is a web dev question this time! I have been learning PHP/jQuery with MySQL and I'm interested in creating an online travel agency kind of site that searched to see which tour guides were available on user selected dates. I'm looking for advice on what may be the best way to store the calendars/availability of all of the guides. My current idea is to only store reserved dates in the guide's table and reference another table which contains rules set by the guide (not available on weekends, prices are $x on these days, etc.). Can anyone see any pitfalls of doing it this way? Does anyone know of a better way I could go about doing this?

Thanks for your help!

Good database design theory is to make tables scalable and to be as specific as possible.

Databases can have constraints set on them if you want. But having an administrative table for things that can change is a good idea.

I learned a lot from here:
https://www.simple-talk.com/sql/database-administration/ten-common-database-design-mistakes/


I don't think it's a good idea to only use two tables for this.

And making calendars is difficult imo. There are many intricacies to dates that are hard to program and php isn't the best language to work with dates.
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.
bangsholt
Profile Joined June 2011
Denmark138 Posts
December 08 2013 11:46 GMT
#8122
On December 07 2013 22:58 sluggaslamoo wrote:
Show nested quote +
On December 06 2013 22:05 bangsholt wrote:
On December 06 2013 12:10 sluggaslamoo wrote:
On December 06 2013 10:27 bangsholt wrote:
On December 05 2013 07:45 sluggaslamoo wrote:
On December 05 2013 00:30 darkness wrote:
Does anyone here like Objective-C? I'm starting to hate it with a passion by now. I find Java's syntax and way much better and easier.


It has some nice features, it was great for its time but I'm sure if it wasn't for apple it would be long dead by now.


Thanks for your opinion and all the great argumentation you have present on the subject of why you are starting to hate it with a passion.

I'm currently playing around with a great mix of Jenkins, Stash and JIRA, in order to make it build automagically and run a few simple static code analysis and unit testing on my code.

People out there who have actual experience with how well this works in a work scenario - I'm thinking it will work great, because it will enable us to put out a lot of metrics, which then can be measured and possibly drawn conclusions on, if someone feels that brave, but I would like to hear from people who have a similar setup as well.

Thanks in advance for your time.


What is it you want to know? Continuous Integration and Testing is one of the reasons I actually get hired haha

I mean yeah I've used Jenkins a lot, JIRA I don't really like but then again I don't really like any kind of digital scrum/agile software and prefer to use real cards, I don't have experience with Stash specifically but Atlassian software seems to be very good in general from using Bamboo.

It will be a long time before I move away from Github though if ever


I've read the idea with CI is that you make a new build every time you commit to the Git server on the master branch.

What I don't really understand is the part where testing comes into the picture, one would assume you run all the tests prior to commit the code, and each commit should be atomic.

Or is it a case of you over time accumulate some tests that take a lot of time to run and you don't want to run each time that you compile?

It's this sort of questions I wonder a bit about - again, thanks for your time


You are pretty much on the ball there, both of those statements are true. Ideally you would want to do a "full build" before pushing to your branch, but in large projects where it takes an hour to do that it is not possible.

So on your local machine you may just be content with core scenario tests, integration tests and unit tests, and then CI handles the bigger picture. Then you have a "build light" that checks CI periodically, and will alarm everybody if someone broke the build and blame them for it

When this happens, everyone should stop committing until the bug is fixed.

Show nested quote +
I've read the idea with CI is that you make a new build every time you commit to the Git server on the master branch.


Got a bit confused by the "make a new build every time", do you mean run the build?

If so yes, normally you have nightly builds, source control event-based and on-demand builds for each type of test, and for each branch. Your event based builds would trigger when your git repository receives an update.

Normally you wouldn't want to be pushing to master, you want to be merging into it from your version branch. There should be a protocol to only merge into master after a "full build" which is basically every single test which sometimes can take hours.

It may look something like this

Master-Nightly-FullBuild
Master-Nightly-Load-Test
Version1.1-Nightly-FullBuild
Version1.1-Unit-Tests
Version1.1-Integration-Tests
Version1.1-Scenario-Tests-Minor
Version1.1-Scenario-Tests-All
Version1.1-E2E-Tests
Version1.1-Load-Test


Yes, I meant run the build

I got a better idea of the whys now, thanks for that to you, phar and Morfildur
ambikalx
Profile Joined September 2011
United States30 Posts
December 08 2013 23:14 GMT
#8123
On December 08 2013 18:29 obesechicken13 wrote:
Good database design theory is to make tables scalable and to be as specific as possible.

Databases can have constraints set on them if you want. But having an administrative table for things that can change is a good idea.

I learned a lot from here:
https://www.simple-talk.com/sql/database-administration/ten-common-database-design-mistakes/


I don't think it's a good idea to only use two tables for this.

And making calendars is difficult imo. There are many intricacies to dates that are hard to program and php isn't the best language to work with dates.


Thanks for the response! That link was just what I needed. I had been absolutely in the dark as far as how to structure my databases/tables. I read up on the entity-relationship model and have a much better idea of what I'm doing now.

Also, I totally forgot that I am actually going to be taking Database Design & Development next semester in my CS major *slaps forehead*. We will be learning about ERM, so I guess I'm going to have a bit of a head start on the class
phar
Profile Joined August 2011
United States1080 Posts
December 09 2013 00:17 GMT
#8124
On December 08 2013 20:46 bangsholt wrote:
Show nested quote +
On December 07 2013 22:58 sluggaslamoo wrote:
On December 06 2013 22:05 bangsholt wrote:
On December 06 2013 12:10 sluggaslamoo wrote:
On December 06 2013 10:27 bangsholt wrote:
On December 05 2013 07:45 sluggaslamoo wrote:
On December 05 2013 00:30 darkness wrote:
Does anyone here like Objective-C? I'm starting to hate it with a passion by now. I find Java's syntax and way much better and easier.


It has some nice features, it was great for its time but I'm sure if it wasn't for apple it would be long dead by now.


Thanks for your opinion and all the great argumentation you have present on the subject of why you are starting to hate it with a passion.

I'm currently playing around with a great mix of Jenkins, Stash and JIRA, in order to make it build automagically and run a few simple static code analysis and unit testing on my code.

People out there who have actual experience with how well this works in a work scenario - I'm thinking it will work great, because it will enable us to put out a lot of metrics, which then can be measured and possibly drawn conclusions on, if someone feels that brave, but I would like to hear from people who have a similar setup as well.

Thanks in advance for your time.


What is it you want to know? Continuous Integration and Testing is one of the reasons I actually get hired haha

I mean yeah I've used Jenkins a lot, JIRA I don't really like but then again I don't really like any kind of digital scrum/agile software and prefer to use real cards, I don't have experience with Stash specifically but Atlassian software seems to be very good in general from using Bamboo.

It will be a long time before I move away from Github though if ever


I've read the idea with CI is that you make a new build every time you commit to the Git server on the master branch.

What I don't really understand is the part where testing comes into the picture, one would assume you run all the tests prior to commit the code, and each commit should be atomic.

Or is it a case of you over time accumulate some tests that take a lot of time to run and you don't want to run each time that you compile?

It's this sort of questions I wonder a bit about - again, thanks for your time


You are pretty much on the ball there, both of those statements are true. Ideally you would want to do a "full build" before pushing to your branch, but in large projects where it takes an hour to do that it is not possible.

So on your local machine you may just be content with core scenario tests, integration tests and unit tests, and then CI handles the bigger picture. Then you have a "build light" that checks CI periodically, and will alarm everybody if someone broke the build and blame them for it

When this happens, everyone should stop committing until the bug is fixed.

I've read the idea with CI is that you make a new build every time you commit to the Git server on the master branch.


Got a bit confused by the "make a new build every time", do you mean run the build?

If so yes, normally you have nightly builds, source control event-based and on-demand builds for each type of test, and for each branch. Your event based builds would trigger when your git repository receives an update.

Normally you wouldn't want to be pushing to master, you want to be merging into it from your version branch. There should be a protocol to only merge into master after a "full build" which is basically every single test which sometimes can take hours.

It may look something like this

Master-Nightly-FullBuild
Master-Nightly-Load-Test
Version1.1-Nightly-FullBuild
Version1.1-Unit-Tests
Version1.1-Integration-Tests
Version1.1-Scenario-Tests-Minor
Version1.1-Scenario-Tests-All
Version1.1-E2E-Tests
Version1.1-Load-Test


Yes, I meant run the build

I got a better idea of the whys now, thanks for that to you, phar and Morfildur

NP. And if you do get pushback from people at your work who are dragging their feet about setting up proper building and testing, you should be able to explain how much time you'll save in the long run if you invest up front.
Who after all is today speaking about the destruction of the Armenians?
misirlou
Profile Joined June 2010
Portugal3306 Posts
December 09 2013 00:37 GMT
#8125
Anyone have experience developing/contributing for Open Stack? My master's is to make a scheduler for it, so any info I could get on working for it and getting started with some community interaction would be appreciated
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
December 09 2013 02:28 GMT
#8126
On December 09 2013 08:14 ambikalx wrote:
Show nested quote +
On December 08 2013 18:29 obesechicken13 wrote:
Good database design theory is to make tables scalable and to be as specific as possible.

Databases can have constraints set on them if you want. But having an administrative table for things that can change is a good idea.

I learned a lot from here:
https://www.simple-talk.com/sql/database-administration/ten-common-database-design-mistakes/


I don't think it's a good idea to only use two tables for this.

And making calendars is difficult imo. There are many intricacies to dates that are hard to program and php isn't the best language to work with dates.


Thanks for the response! That link was just what I needed. I had been absolutely in the dark as far as how to structure my databases/tables. I read up on the entity-relationship model and have a much better idea of what I'm doing now.

Also, I totally forgot that I am actually going to be taking Database Design & Development next semester in my CS major *slaps forehead*. We will be learning about ERM, so I guess I'm going to have a bit of a head start on the class

No problem. I took an intro to databases course this semester and I thought that link helped me a lot to understand entity relationship design.
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.
jWavA
Profile Joined January 2011
United States73 Posts
December 09 2013 04:38 GMT
#8127
I've got my first ever technical interview tomorrow, with Google for their Eng. Practicum Internship. Any advice?
Kambing
Profile Joined May 2010
United States1176 Posts
December 09 2013 07:47 GMT
#8128
On December 09 2013 13:38 jWavA wrote:
I've got my first ever technical interview tomorrow, with Google for their Eng. Practicum Internship. Any advice?


Talk. Specifically, when you work through problems, vocalize your thought process to the best of your ability. Interview questions are meant to expose how you think, and you won't be able to show that off without saying something.
epok
Profile Joined September 2013
United States117 Posts
December 09 2013 17:34 GMT
#8129
Don't lie to your interviewer!
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2013-12-10 02:31:44
December 10 2013 02:30 GMT
#8130
^ These are very good tips. Always think out loud, that way the interviewer can write effective feedback on what you're thinking. Never lie, because interviewers can tell

If you take only one thing from TL on interview tips, let it be what Kambing said above. THINK OUTLOUD. Even if you're stuck, keep describing why you're stuck, where you're drawing blanks, what you know and what you think you don't know. It's really weird to get used to at first, but it is a necessary thing for technical interviews.

On December 09 2013 13:38 jWavA wrote:
I've got my first ever technical interview tomorrow, with Google for their Eng. Practicum Internship. Any advice?


Specifically on the EP part, realize that the interviewers should know that you have less experience than a normal interview candidate. If you don't know something, that's fine, just be up front about it so you don't work yourself into a hole. I hosted a couple of EP interns this summer, and they were definitely very green about software development coming in. That's ok, and your interview should be calibrated to take that into account.

It may be a bit rough if this is really your first technical interview, it can take awhile to get used to.


And then one of the local Googlers up here has a... rant, we'll say, on google interview process. It's mostly geared towards fulltime SWE, not EP, but a lot of it will apply. The middle sections on algorithms, data structures, practice, Big-O, it's all pretty good. I can't remember if EP are explicitly supposed to know about complexity theory, so if there's some stuff on there that you don't recognize, it may not apply for you. Also your recruiter may have given you more detail about what you're expected to know.

http://steve-yegge.blogspot.com/2008/03/get-that-job-at-google.html

Even if you don't get in, don't be discouraged, apply again next year, and apply to many places. You'd be a freshman or sophomore right now if you're applying for EP, so you have time still


good luck~
Who after all is today speaking about the destruction of the Armenians?
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-12-11 04:26:15
December 11 2013 04:22 GMT
#8131
Say a user cannot cause a crash, but a programmer may pass some parameter that is out of boundaries. Is it good in this case to have all methods contain some boundary check (even if the programmer is the only person able to cause it) or is such check unnecessary?

Sub-question to the above one. What is preferred assuming both are available: if statement or try/catch blocks? When to go one over another?

I'm curious what to do for my individual university project. I'd like to do my best with the knowledge I have at the moment.

I use Java if it matters.
Kambing
Profile Joined May 2010
United States1176 Posts
December 11 2013 04:35 GMT
#8132
On December 11 2013 13:22 darkness wrote:
Say a user cannot cause a crash, but a programmer may pass some parameter that is out of boundaries. Is it good in this case to have all methods contain some boundary check (even if the programmer is the only person able to cause it) or is such check unnecessary?

Sub-question to the above one. What is preferred assuming both are available: if statement or try/catch blocks? When to go one over another?

I'm curious what to do for my individual university project. I'd like to do my best with the knowledge I have at the moment.

I use Java if it matters.


You allude to it in your problem description, but the way to think about error-handling is asking yourself the question "is this a user-facing or internal API"? Users are considered untrustworthy and if there is a way to break or otherwise exploit your system, they will do it. In contrast, you trust yourself to do the "right thing" because you have control over how you use the system.

Regardless of the answer to this question, these sorts of pre-conditions you impose on your functions (resp. programs) should be documented in some form, e.g., in a comment. They are part of the interface to those functions and must be respected for your functions to perform as expected.

Whether you introduce more safe guards other than documentation depends on your answer to the question above. In the case of internal APIs, it is fine to not include any explicit checks. Some languages such as Java allow for assertions to be expressed that fit this mold. The statement assert e; evaluates the boolean expression e and raises an error if e is false. These asserts can be toggled on (for debugging) and off (for deployment) via flags to the compiler.

For user-facing APIs, it is a matter of good style to either "engineer" out these corner cases or otherwise provide internal checking to ensure that the inputs to the functions meet the functions' pre-conditions. If-statements are appropriate for this purpose. Try-catch blocks are typically reserved for exceptional cases that might occur during the execution of a function, e.g., a network socket getting yanked while you are reading in packets. They are not appropriate for merely checking these sorts of pre-conditions.

Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2013-12-11 07:20:08
December 11 2013 07:17 GMT
#8133
--- Nuked ---
windzor
Profile Joined October 2010
Denmark1013 Posts
Last Edited: 2013-12-11 09:15:05
December 11 2013 09:13 GMT
#8134
On December 11 2013 13:22 darkness wrote:
Say a user cannot cause a crash, but a programmer may pass some parameter that is out of boundaries. Is it good in this case to have all methods contain some boundary check (even if the programmer is the only person able to cause it) or is such check unnecessary?

Sub-question to the above one. What is preferred assuming both are available: if statement or try/catch blocks? When to go one over another?

I'm curious what to do for my individual university project. I'd like to do my best with the knowledge I have at the moment.

I use Java if it matters.


If you need to check parameter values for which you have set up preconditions but dont check for them in the code you should use asserts. It will be easy to read from your code what boundaries you expect the function to work in without the user having the hassle with errors which might not be errors.

How much you want to do it is a cost/benefit of how many errors you will catch from yourself vs how long you use on writing them.
Yeah
billy5000
Profile Blog Joined December 2010
United States865 Posts
December 11 2013 18:57 GMT
#8135
I have a question about databases. I took a dbms course last semester, and we specifically used psql. At the same time I was taking a mongodb course online as well. One thing that caught my attention was how easy it is to scale mongodb due to its flexibility, but this brings up a question: How do relational databases scale? It seems like you have to know all the details, such as the relationships between tables, before the application is built. And adding any extra features may denormalize the relationships you had before and just complicate things further (sorry, I haven't built anything big yet, so I don't have any concrete examples).
Tiger got to hunt, bird got to fly; Man got to sit and wonder, 'Why, why, why?' Tiger got to sleep, bird got to land; Man got to tell himself he understand. Vonnegut
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
December 11 2013 20:35 GMT
#8136
On December 11 2013 18:13 windzor wrote:
Show nested quote +
On December 11 2013 13:22 darkness wrote:
Say a user cannot cause a crash, but a programmer may pass some parameter that is out of boundaries. Is it good in this case to have all methods contain some boundary check (even if the programmer is the only person able to cause it) or is such check unnecessary?

Sub-question to the above one. What is preferred assuming both are available: if statement or try/catch blocks? When to go one over another?

I'm curious what to do for my individual university project. I'd like to do my best with the knowledge I have at the moment.

I use Java if it matters.


If you need to check parameter values for which you have set up preconditions but dont check for them in the code you should use asserts. It will be easy to read from your code what boundaries you expect the function to work in without the user having the hassle with errors which might not be errors.

How much you want to do it is a cost/benefit of how many errors you will catch from yourself vs how long you use on writing them.


Aren't asserts only for testing/debugging? I've searched for that on google, and I didn't find very positive suggestions to keep asserts in code for long.
tofucake
Profile Blog Joined October 2009
Hyrule19228 Posts
December 11 2013 21:08 GMT
#8137
Asserts in deployment are a pain in the ass.
Liquipediaasante sana squash banana
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
December 11 2013 21:24 GMT
#8138
On December 11 2013 13:22 darkness wrote:
Say a user cannot cause a crash, but a programmer may pass some parameter that is out of boundaries. Is it good in this case to have all methods contain some boundary check (even if the programmer is the only person able to cause it) or is such check unnecessary?

Sub-question to the above one. What is preferred assuming both are available: if statement or try/catch blocks? When to go one over another?

I'm curious what to do for my individual university project. I'd like to do my best with the knowledge I have at the moment.

I use Java if it matters.


For me there is one golden rule for error checking in programming:
In every userbase, no matter how big or small, there is at least one user that will manage to get the system into an invalid state. If you are the only user of the system (or method), it will eventually be you.

That means, even if you think you know that you always pass the right parameters into a function, eventually you will mix something up or forget the boundary conditions. That is why i check every parameter to every function (It's really not that much in a strongly typed language like java) because i know that eventually i will screw up. Noone remembers how the code he wrote 6 month ago really works in detail. There are some minor exceptions, for example in private methods i'm less strict about checking, though i still do check most of the input.

Then again, i'm really, really paranoid.
Kambing
Profile Joined May 2010
United States1176 Posts
December 11 2013 22:49 GMT
#8139
On December 12 2013 05:35 darkness wrote:
Show nested quote +
On December 11 2013 18:13 windzor wrote:
On December 11 2013 13:22 darkness wrote:
Say a user cannot cause a crash, but a programmer may pass some parameter that is out of boundaries. Is it good in this case to have all methods contain some boundary check (even if the programmer is the only person able to cause it) or is such check unnecessary?

Sub-question to the above one. What is preferred assuming both are available: if statement or try/catch blocks? When to go one over another?

I'm curious what to do for my individual university project. I'd like to do my best with the knowledge I have at the moment.

I use Java if it matters.


If you need to check parameter values for which you have set up preconditions but dont check for them in the code you should use asserts. It will be easy to read from your code what boundaries you expect the function to work in without the user having the hassle with errors which might not be errors.

How much you want to do it is a cost/benefit of how many errors you will catch from yourself vs how long you use on writing them.


Aren't asserts only for testing/debugging? I've searched for that on google, and I didn't find very positive suggestions to keep asserts in code for long.


Asserts are meant to capture pre-conditions/invariants in your code that are not explicitly checked. They are precisely the set of properties about your code that are "assumptions" that you assume will hold but trust the user of that code to get right. For example:

"The argument to factorial should be non-negative."
"Your helper function expects a non-null object."
"Your file processing function expects a file handled that has been opened but not yet closed."

In particular, the Java assert statement lets you express these in code versus in comments and gives you mechanism to have them checked (morally, when debugging) or not checked (morally, when deploying) as needed.
Kambing
Profile Joined May 2010
United States1176 Posts
December 12 2013 01:29 GMT
#8140
FYI, this week is Computer Science Education week!

http://csedweek.org/

This year, the code.org are pushing a nationwide movement for everyone to spend an hour of their time this week to learn how to code or teach a friend or family member how to code. Check out:

http://csedweek.org/learn

For tutorials for virtually all ages for a variety of technologies, with and without computers!
Prev 1 405 406 407 408 409 1032 Next
Please log in or register to reply.
Live Events Refresh
CrankTV Team League
11:00
Crank Gathers S4: Group Stage
LiquipediaDiscussion
Replay Cast
09:00
Crank Gathers S4: Group Stage
CranKy Ducklings100
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 166
BRAT_OK 79
OGKoka 47
StarCraft: Brood War
Calm 3514
Rain 2939
Sea 1692
Jaedong 702
Shuttle 589
Hyuk 567
BeSt 354
Mini 321
Light 213
EffOrt 188
[ Show more ]
Soma 157
Soulkey 151
Zeus 134
firebathero 132
Hyun 129
Larva 120
Snow 110
ggaemo 100
hero 65
Free 55
JYJ 55
ZerO 54
scan(afreeca) 47
Sharp 42
Rush 41
sorry 40
Movie 40
soO 34
Sacsri 21
Bale 19
Hm[arnc] 18
Terrorterran 16
Yoon 15
zelot 15
Sexy 13
IntoTheRainbow 13
JulyZerg 12
Barracks 11
Sea.KH 8
ajuk12(nOOB) 7
Purpose 7
Dota 2
Gorgc2390
Fuzer 128
League of Legends
Doublelift934
JimRising 355
Other Games
gofns9028
singsing1239
crisheroes308
Lowko258
XaKoH 163
B2W.Neo150
Happy120
amsayoshi73
Trikslyr14
ZerO(Twitch)14
Organizations
Other Games
gamesdonequick2393
BasetradeTV162
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 15 non-featured ]
StarCraft 2
• Berry_CruncH322
• StrangeGG 80
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• escodisco2110
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1142
• Stunt427
Upcoming Events
WardiTV Qualifier
53m
Epic.LAN
1h 53m
Big Brain Bouts
4h 53m
SHIN vs Elazer
Percival vs Nicoract
Reynor vs Lambo
Replay Cast
12h 53m
RSL Revival
21h 53m
Clem vs Lambo
Scarlett vs Cure
CranKy Ducklings
22h 53m
Epic.LAN
1d 1h
IPSL
1d 4h
Dragon vs Hawk
RSL Revival
1d 21h
Classic vs Trap
herO vs SHIN
Sparkling Tuna Cup
1d 22h
[ Show More ]
OSC
2 days
IPSL
2 days
Bonyth vs Ret
WardiTV Weekly
2 days
Monday Night Weeklies
3 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
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...

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.