|
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. |
On March 14 2012 20:12 supereddie wrote:Show nested quote +On March 14 2012 16:27 Yiko wrote:On March 14 2012 04:21 supereddie wrote: Why not use just normal javascript? Can't be that hard to create a toggle function... You are right, it really isn't. But why would you not use a library that makes that even easier, produces easy to understand code and specialises in element selection and manipulation, which is exactly what was wanted in the first place? I have to admit, i often use JQuery even in places where plain JavaScript would easily suffice, because it is just so powerful and convenient. I don't know... I think JQuery promotes lazyness and sloppy markup (much like PHP), especially for beginners, by not properly introducing DOM and html/css/javascript. Not knowing the right element to use in your markup is a sign to this. ... Second, for a structured layout, the .bbspoiler DIV should be inside the element that has the onclick event so everything is nicely grouped together. In addition, one might also move the 'Show Spoiler' text into the grouped div.
I would not go as far as saying that it actively promotes laziness, but it definitely allows for it so i can see your point. Sloppy markup on the other hand is imho completly unrelated to JQuery/not JQuery. It comes down to the experience of the developer and his knowledge of html/css/the dom. Neither pure javascript nor jquery force you to create well structured documents with correct markup decisions. I have seen equally horrid stuff created in relation to pure js as with jquery.
I have to disagree with your second point though, putting the spoiler-content within the area that has the onClick handler attached would imho create a strange usability. Clicking the content should not hide it again, that is what the "handle" is for. This would make stuff like selecting text within the spoiler, or clicking a link uncomfortable because the content would disappear again. But thats just nitpicking or maybe personal preference 
Enough derailing! 
|
Why do I always read programming as progaming...
First. World. Problems.
|
On March 15 2012 00:53 MaV_gGSC wrote: Why do I always read programming as progaming...
First. World. Problems.
Strange. I'm affected by the same phenomenon, only the inverse.
|
Hyrule18977 Posts
The worst is when someone is afflicted by both and refers to both as "programing"
|
On March 14 2012 20:12 supereddie wrote:Show nested quote +On March 14 2012 16:27 Yiko wrote:On March 14 2012 04:21 supereddie wrote: Why not use just normal javascript? Can't be that hard to create a toggle function... You are right, it really isn't. But why would you not use a library that makes that even easier, produces easy to understand code and specialises in element selection and manipulation, which is exactly what was wanted in the first place? I have to admit, i often use JQuery even in places where plain JavaScript would easily suffice, because it is just so powerful and convenient. I don't know... I think JQuery promotes lazyness and sloppy markup (much like PHP), especially for beginners, by not properly introducing DOM and html/css/javascript. Not knowing the right element to use in your markup is a sign to this. Take Kentor's markup: <a href='#' class='spoiler monospace' title='asdf'>+ Show Spoiler [asdf] +</a> <div class='bbspoiler'>test</div> This is 'wrong' on a few levels. Firstly, the A shouldn't be an A. It should either be a SPAN, or a DIV. An A is used to redirect to a different page or to an anchor on the same page. Both of these are not used here - instead the A is used only for the onclick event, for which you can easliy use the more appropiate elements. Whenever you find yourself setting the href attribute to "#" and attaching an onclick event, consider using a SPAN or DIV element instead. Second, for a structured layout, the .bbspoiler DIV should be inside the element that has the onclick event so everything is nicely grouped together. In addition, one might also move the 'Show Spoiler' text into the grouped div. Here's my version (I had a few spare minutes): + Show Spoiler +<html> <head> <title>Toggle</title> <style> .spoiler{ background-color: white; width: 600px; } .spoiler:hover{ cursor: pointer; } .spoiler > span {color:grey;} .spoiler > div { border: 1px solid black; display: none; margin: 0 10px 10px 10px; } </style> <script type="text/javascript"> function toggle(element) { d = element.getElementsByTagName('div')[0]; s = element.getElementsByTagName('span')[0]; title = element.getAttribute('title'); text = "Spoiler "; if(title !== null) text += "[" + title + "]"; if(d.style.display === 'block') { s.childNodes[0].nodeValue = '+ Show ' + text + ' +'; d.style.display = 'none'; } else { s.childNodes[0].nodeValue = '- Hide ' + text + ' -' ; d.style.display = 'block'; } } </script> </head>
<body> <div class='spoiler' title='asdf' onclick="toggle(this)"> <span>+ Show Spoiler [asdf] +</span> <div>test asdjdsf sdf df </div> </div> </body> </html>
The A elements *should* be A elements. Spans and divs are not interactive content, and not focusable (without ARIA-attributes, anyway), so they should not be used as such. Your code is not at all accessible to people who don't use a mouse to browse, such as people who use keyboard-only or use a screenreader.
From the list interactive content elements here you'll notice that the only other acceptable type for this usage would be a button. Since this is designed to be just text, however, an A tag makes far more sense.
I agree about moving it into a grouped div ($.next() is a maintenance problem waiting to happen), but I find it absolutely hilarious that you bitched about jQuery making people lazy and sloppy and then use the onclick attribute. Seriously?
|
On March 14 2012 22:04 Yiko wrote:Show nested quote +On March 14 2012 20:12 supereddie wrote:On March 14 2012 16:27 Yiko wrote:On March 14 2012 04:21 supereddie wrote: Why not use just normal javascript? Can't be that hard to create a toggle function... You are right, it really isn't. But why would you not use a library that makes that even easier, produces easy to understand code and specialises in element selection and manipulation, which is exactly what was wanted in the first place? I have to admit, i often use JQuery even in places where plain JavaScript would easily suffice, because it is just so powerful and convenient. I don't know... I think JQuery promotes lazyness and sloppy markup (much like PHP), especially for beginners, by not properly introducing DOM and html/css/javascript. Not knowing the right element to use in your markup is a sign to this. ... Second, for a structured layout, the .bbspoiler DIV should be inside the element that has the onclick event so everything is nicely grouped together. In addition, one might also move the 'Show Spoiler' text into the grouped div. I would not go as far as saying that it actively promotes laziness, but it definitely allows for it so i can see your point. Sloppy markup on the other hand is imho completly unrelated to JQuery/not JQuery. It comes down to the experience of the developer and his knowledge of html/css/the dom. Neither pure javascript nor jquery force you to create well structured documents with correct markup decisions. I have seen equally horrid stuff created in relation to pure js as with jquery. I have to disagree with your second point though, putting the spoiler-content within the area that has the onClick handler attached would imho create a strange usability. Clicking the content should not hide it again, that is what the "handle" is for. This would make stuff like selecting text within the spoiler, or clicking a link uncomfortable because the content would disappear again. But thats just nitpicking or maybe personal preference Enough derailing! 
I'm not very good at listening, so I'm going to take over the derailment.
Making a statement that jquery (and php) promote laziness is an extremely bold move. Laziness is on the developer, not on the language or library. The tool you are using provides you with the ability to accomplish your tasks, if you choose not to dive into the tool to gather a better understanding, is that really the tools fault? I certainly don't think so.
I still believe you are overlooking a key factor to the decision to use jQuery. Cross browser support is a pain in the ass. While I admit that web standards are making things easier to deal with, why reinvent the wheel? The jQuery team has spent countless hours and has large community support to make sure that their javascript works in as many of the supported browsers possible.
Maybe I've been using open source software too long, but I give a huge +1 to any developer choosing to write as little code as possible to complete their task while gaining as much benefit from others work as possible.
|
I can't do this...I have been trying to look up for help but i cant find it (been trying for 2 days so maybe someone else can help me).
side note: I am still new to this and learning c++. I know some stuff (like functions, loops, arrays etc...) xD
Anyway I am trying to create a tic tac toe with visual c++ but I need help creating the board and trying to write something that would help tell the computer to put an "x" or an "o" at w.e square space the user wants to do AND show/re-draw the updated board with the new move. I have tried various things but i don't understand it...
http://www.dreamincode.net/forums/topic/135129-the-tic-tac-toe-program/ ^^I have studied the code for awhile but considering its C language there are somethings in there i dont understand (like how the person is able to printf the board and yet somehow associate the board space to a specific array coordinate, which is shown near the end). I dont need help on how to figure out the winner or getting the input from the player. I was wondering if someone could show me/help me figure out how to create and initialize the board (I would also like an explanation behind the mechanic/process).
edit: I have created text based D&D game. Tic tac is way harder to create :/ although I have a feeling that my incomplete knowledge of c++ is hinduring me from creating something so simple
|
This may or may not have already been asked but Im at work and need to make this quick before Im found out!! Do you have to be really amazing at maths? Math was never my strong point but Ive been interested in programming.
|
On March 15 2012 12:53 ScruffyJanitor wrote:This may or may not have already been asked but Im at work and need to make this quick before Im found out!!  Do you have to be really amazing at maths? Math was never my strong point but Ive been interested in programming. no not really just simple arithmetic and maybe some statistics. You just need to be logical and have some form of critical thinking (innovative helps too).
|
On March 15 2012 12:53 ScruffyJanitor wrote:This may or may not have already been asked but Im at work and need to make this quick before Im found out!!  Do you have to be really amazing at maths? Math was never my strong point but Ive been interested in programming. Programming isn't heavy on math computation, but it uses a lot of problem solving skills that are very important to math.
|
On March 15 2012 12:53 ScruffyJanitor wrote:This may or may not have already been asked but Im at work and need to make this quick before Im found out!!  Do you have to be really amazing at maths? Math was never my strong point but Ive been interested in programming. Nah, but game programming certainly requires a whole lot of math.
|
it really depends on what kind of math you are talking about. Strictly speaking, all that programming syntax grammar, all that condition logic, all your variables, all your algorithms and termination proofs and runtime complexity analyses, your whole program is nothing but discrete math. But i can understand people not considering that to be real math. The beefy stuff like differential equations, limes, solving equation systems and whatnot are not needed very often, and if you do need them you have to look up how to handle that stuff anyways.
The discrete math and logic stuff you have to know though. That's not something you can look up every time.
|
On March 15 2012 12:53 ScruffyJanitor wrote:This may or may not have already been asked but Im at work and need to make this quick before Im found out!!  Do you have to be really amazing at maths? Math was never my strong point but Ive been interested in programming.
Most you would need on enterprise level would be High School maths. Game programming and physics simulation would require more advance level of maths tho
|
On March 15 2012 18:55 Herper wrote:Show nested quote +On March 15 2012 12:53 ScruffyJanitor wrote:This may or may not have already been asked but Im at work and need to make this quick before Im found out!!  Do you have to be really amazing at maths? Math was never my strong point but Ive been interested in programming. Most you would need on enterprise level would be High School maths. Game programming and physics simulation would require more advance level of maths tho This. I'm terrible at math and I work fulltime as a programmer. When making games etc, you need to be able to work with vectors etc and math helps out a ton, but for making standard applications used by companies, apps for mobile phones etc, you basically need zero math... Most libraries already have all the algoritms etc you need built in, you don't need to worry about that stuff.
|
Guys, it's been years since I touched Java, could you tell me if that even makes sense?
interface Shipyard { String returnShipClass (String _shipClass); int[] returnShipEngineStats (int _shipSpeed, int _shipTurnRate, int _shipSignatureRadius); int[] retrunShipHullStats (int _shipStructure, int _shipShields, int _shipArmour); int[][] returnShipImperialCapitalHullStats (int _shipStructure, int _shipShields, int[] _shipImperialCapitalArmour); }
abstract class ShipConstructor implements Shipyard { private String shipClass; private int shipStructure; private int shipShields; private int shipSpeed; private int shipSignatureRadius; private int shipTurnRate; private int shipArmour; private int[] shipImperialCapitalArmour = new int[2]; private int[] shipEngineStats = new int[3]; private int[] shipHullStats = new int[3]; private int[][] shipImperialCapitalHullStats = new int[2][2]; public String returnShipClass (String _shipClass) { shipClass = _shipClass; return shipClass; } public int[] returnShipEngineStats (int _shipSpeed, int _shipTurnRate, int _shipSignatureRadius) { shipSpeed = _shipSpeed; shipTurnRate = _shipTurnRate; shipSignatureRadius = _shipSignatureRadius; shipEngineStats[0] = shipSpeed; shipEngineStats[1] = shipTurnRate; shipEngineStats[2] = shipSignatureRadius; return shipEngineStats; } public int[] returnShipHullStats (int _shipStructure, int _shipShields, int _shipArmour) { shipStructure = _shipStructure; shipShields = _shipShields; shipArmour = _shipArmour; shipHullStats[0] = shipStructure; shipHullStats[1] = shipShields; shipHullStats[2] = shipArmour; return shipHullStats; } public int[][] returnShipImperialCapitalHullStats (int _shipStructure, int _shipShields, int[] _shipImperialCapitalArmour) { shipStructure = _shipStructure; shipShields = _shipShields;
shipImperialCapitalArmour[0] = _shipImperialCapitalArmour[0]; shipImperialCapitalArmour[1] = _shipImperialCapitalArmour[1];
shipImperialCapitalHullStats[0][0] = shipStructure; shipImperialCapitalHullStats[0][1] = shipShields; shipImperialCapitalHullStats[1][0] = shipImperialCapitalArmour[0]; shipImperialCapitalHullStats[1][1] = shipImperialCapitalArmour[1]; return shipImperialCapitalHullStats; } }
|
On March 15 2012 19:52 Manit0u wrote:Guys, it's been years since I touched Java, could you tell me if that even makes sense? interface Shipyard { String returnShipClass (String _shipClass); int[] returnShipEngineStats (int _shipSpeed, int _shipTurnRate, int _shipSignatureRadius); int[] retrunShipHullStats (int _shipStructure, int _shipShields, int _shipArmour); int[][] returnShipImperialCapitalHullStats (int _shipStructure, int _shipShields, int[] _shipImperialCapitalArmour); }
abstract class ShipConstructor implements Shipyard { private String shipClass; private int shipStructure; private int shipShields; private int shipSpeed; private int shipSignatureRadius; private int shipTurnRate; private int shipArmour; private int[] shipImperialCapitalArmour = new int[2]; private int[] shipEngineStats = new int[3]; private int[] shipHullStats = new int[3]; private int[][] shipImperialCapitalHullStats = new int[2][2]; public String returnShipClass (String _shipClass) { shipClass = _shipClass; return shipClass; } public int[] returnShipEngineStats (int _shipSpeed, int _shipTurnRate, int _shipSignatureRadius) { shipSpeed = _shipSpeed; shipTurnRate = _shipTurnRate; shipSignatureRadius = _shipSignatureRadius; shipEngineStats[0] = shipSpeed; shipEngineStats[1] = shipTurnRate; shipEngineStats[2] = shipSignatureRadius; return shipEngineStats; } public int[] returnShipHullStats (int _shipStructure, int _shipShields, int _shipArmour) { shipStructure = _shipStructure; shipShields = _shipShields; shipArmour = _shipArmour; shipHullStats[0] = shipStructure; shipHullStats[1] = shipShields; shipHullStats[2] = shipArmour; return shipHullStats; } public int[][] returnShipImperialCapitalHullStats (int _shipStructure, int _shipShields, int[] _shipImperialCapitalArmour) { shipStructure = _shipStructure; shipShields = _shipShields;
shipImperialCapitalArmour[0] = _shipImperialCapitalArmour[0]; shipImperialCapitalArmour[1] = _shipImperialCapitalArmour[1];
shipImperialCapitalHullStats[0][0] = shipStructure; shipImperialCapitalHullStats[0][1] = shipShields; shipImperialCapitalHullStats[1][0] = shipImperialCapitalArmour[0]; shipImperialCapitalHullStats[1][1] = shipImperialCapitalArmour[1]; return shipImperialCapitalHullStats; } }
Not really. The "return" functions seem to have the responsibility to both obfuscate, store and return values. All the arrays also seem to be completely useless/redundant and included just for the hell of it. Basically the code does absolutely nothing.
EDIT: to clarify, try picking one line from that block that expresses some logic or performs some useful operation
EDIT2: nodeJS and AngularJS are the coolest new kids on the block and will be the next big things Angular's performance is a bit iffy on mobile devices though...
EDIT3: i said "both" for three things; dumass poppet
|
looks like you are abusing arrays because you are too lazy to make a proper classes and only works because you are lucky enough not to use any types besides int yet.
also, for conventions sake: call methods getX for simple getters, maybe calculateX for calculation intensive getters. but you shouldn't call them returnX, because that's rather painful to read.
|
MONGOOOOOOOOOODB - thoughts?
|
On March 15 2012 20:27 fonger wrote: MONGOOOOOOOOOODB - thoughts?
funny thing, but clustering functionality is (was when i looked at it last about a year ago) horribly to control through client applications because of lacking support through the various language drivers (at least java). If you want to manage a mongodb instance as an in-application database you'll have to pipe it a ton, not fun. But well, that's not really what it was designed for. Haven't used it in it's primary use case as manually set up database for some clustered web application.
Oh and also, when using from java, the lack of a proper object<->document mapping (like hibernate for o/r mapping) is a bit ugly, next time i take a shot at it i'd definitely try to see if i can marshall my objects through gson and just write them in string form to the driver, rather than trying to build a marshaller of my own that uses the java drivers DBObject api directly :X such a stupid idea
|
From what I read about design in Java, you should avoid getters and setters at all costs. Just like you should avoid extends.
Anyway, what I'm trying to do here is the C equivalent of Struct for simple data storage which would communicate with other classes through interface. But like I said, it's been years since I did any Java and recently I was mostly doing structural programming so going into OO might take me some time to getting used to.
|
|
|
|