Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,913 members, 7,806,651 topics. Date: Tuesday, 23 April 2024 at 07:54 PM

I Can Code In 75 Languages!!! - Programming (5) - Nairaland

Nairaland Forum / Science/Technology / Programming / I Can Code In 75 Languages!!! (14451 Views)

Learning To Code In Naijarea / I Need Online Banking Source Code In PHP, MSQL / Online Banking Source Code In PHP, MSQL (2) (3) (4)

(1) (2) (3) (4) (5) (6) (7) (Reply) (Go Down)

Re: I Can Code In 75 Languages!!! by FincoApps(m): 8:44am On Jul 20, 2016
KazukiIto:


I'm not old dsql18. I'm just a student of the Old and hopefully, will be a leader of the New. There is no soul in hackerism any longer. I'm so sad. Everyone is interested is copying and pasting calculator programs in the name of having a 'portfolio'. Nothing clever anymore. So sad

Dude, whether you like it or not, you must use the result of other people work.... it does not make you lazy. That's why there are scientists.... they help to discover things and easier ways to do things. People like you that want to do everything the hard way would be a scientist, but your works would probably be only taught when you are long gone...

So I and most other programmers prefer not to be scientists and use what the other scientists has made
Re: I Can Code In 75 Languages!!! by godofbrowser(m): 2:10am On Jul 22, 2016
DanielTheGeek:
Well, who can tell me my top three best languages merely by looking at this code?
Note: I purposely didn't comment my code


<?php
class language {
var $language;
function __construct( $new_language ) {
$this->language = $new_language;
}
function get_language() {
return $this->language;
}
function set_language() {
return $this->language;
}
}
$lang_array = [
'JavaScript' ,
'PHP' ,
'Java' ,
'Ruby' ,
'GoLang' ,
'Python' ,
'Haskell' ,
'C#'
];
$first_real_lang = new language( $lang_array[1]) ;
$second_real_lang = new language( $lang_array[0]) ;
$third_real_lang = new language( $lang_array[5]) ;
?>
<button id="button" onclick="showLangs( this,'langDiv' ) ; "
<div style="display:none;" id="langDiv">
<?= "My major most used languages are: <b>".$first_real_lang
<b>".$second_real_lang->get_language()."</b> and <b>".$thir
</div>
<script type='text/javascript' >
window.onload = function() {
var r = confirm( 'You are about to find out what my
var host = ' http://localhost/ ' ;
if ( r == false ) {
window.location = host;
}
}
function showLangs( h, d ) {
var t = document.getElementById( d ) ;
var b = document.getElementById( h ) ;
if ( t != "" ) {
t.style.display = "block" ;
t.style.padding = "10px" ;
t.style.width = "450px" ;
t.style.backgroundColor = "#2980b9" ;
h.style.display = "none" ;
}
}
</script>


15,000k if you get it in 5mins10secs
Note: Beginners only grin

Copy the code and save it then preview it on your browser to find out.

Your onclick event needs review Cos even without running the code, I can tell from experience that "this" as an argument won't give u the name of the id but will rather return it as an html object. also, u can't place "this" and another argument that way together. there is a trick to doing that. There's every possibility that this code won't run properly.
Re: I Can Code In 75 Languages!!! by Nobody: 3:54am On Jul 22, 2016
^^^Interesting, visual debuggers ni awon eleyi o.
Re: I Can Code In 75 Languages!!! by Nobody: 8:10am On Jul 22, 2016
godofbrowser:


Your onclick event needs review Cos even without running the code, I can tell from experience that "this" as an argument won't give u the name of the id but will rather return it as an html object. also, u can't place "this" and another argument that way together. there is a trick to doing that. There's every possibility that this code won't run properly.

Well, run it first and find out by yourself not with your mouth.
Re: I Can Code In 75 Languages!!! by Nobody: 8:41am On Jul 22, 2016
DanielTheGeek:


Well, run it first and find out by yourself not with your mouth.
*coughs* ever heard of a code-to-mouth-debugger engine!

1 Like

Re: I Can Code In 75 Languages!!! by Craigston: 9:42am On Jul 22, 2016
godofbrowser:


Your onclick event needs review Cos even without running the code, I can tell from experience that "this" as an argument won't give u the name of the id but will rather return it as an html object. also, u can't place "this" and another argument that way together. there is a trick to doing that. There's every possibility that this code won't run properly.
You're correct. The html object is return to the parameter 'h' in the showLangs function. The code will run properly but the 'var b' is unused and should be removed.

2 Likes

Re: I Can Code In 75 Languages!!! by godofbrowser(m): 9:45am On Jul 22, 2016
DanielTheGeek:


Well, run it first and find out by yourself not with your mouth.

I don't think that would be necessary.
Reasons

The poster created a variable "b" on line 44 in a wrong way which would never work with that kinda onclick function you have on line 28.
He probably figured out his code was wrong and used h.style on line 50 instead of the declared "b".

It's important to note that "getElementById( h )" won't give u "getElementById( 'button' )", rather it will produce "getElementById( HTMLDomObject )" and this object ought to be used directly the way he later did on line 50.

The code works. I like his code cos i'm a fan of short clean codes, but then this error was almost a serious issue.

3 Likes

Re: I Can Code In 75 Languages!!! by Nobody: 10:15am On Jul 22, 2016
O boy, see code battle as e dey go o!
Re: I Can Code In 75 Languages!!! by godofbrowser(m): 10:43am On Jul 22, 2016
dhtml18:
O boy, see code battle as e dey go o!

lol... na comedy u come do today abi
Re: I Can Code In 75 Languages!!! by Nobody: 12:08pm On Jul 22, 2016
godofbrowser:


lol... na comedy u come do today abi
funny
Re: I Can Code In 75 Languages!!! by tr3y(m): 1:51pm On Jul 22, 2016
Should have pass in the event object instead of this

1 Like

Re: I Can Code In 75 Languages!!! by Nobody: 4:30pm On Jul 22, 2016
godofbrowser:


I don't think that would be necessary.
Reasons

The poster created a variable "b" on line 44 in a wrong way which would never work with that kinda onclick function you have on line 28.
He probably figured out his code was wrong and used h.style on line 50 instead of the declared "b".

It's important to note that "getElementById( h )" won't give u "getElementById( 'button' )", rather it will produce "getElementById( HTMLDomObject )" and this object ought to be used directly the way he later did on line 50.

The code works. I like his code cos i'm a fan of short clean codes, but then this error was almost a serious issue.

I'm impressed with your review, I never consciously noticed that error... but I probably figured out it won't run If i used the b variable...my spider sense saw that coming cheesy plus I wrote this code online in some few minutes without even running it. I had to run it when @godofbrowser pointed out an error, that mistake can be forgiven.

@godofbrowser I would have downvoted your review if NairaLand had that feature, because the code will still run properly and the presence of only one unused variable/bad variable doesn't make the whole thing useless.
Re: I Can Code In 75 Languages!!! by Nobody: 4:43pm On Jul 22, 2016
tr3y:
Should have pass in the event object instead of this

Yeah, I know right
Re: I Can Code In 75 Languages!!! by godofbrowser(m): 6:18pm On Jul 22, 2016
DanielTheGeek:


I'm impressed with your review, I never consciously noticed that error... but I probably figured out it won't run If i used the b variable...my spider sense saw that coming cheesy plus I wrote this code online in some few minutes without even running it. I had to run it when @godofbrowser pointed out an error, that mistake can be forgiven.

@godofbrowser I would have downvoted your review if NairaLand had that feature, because the code will still run properly and the presence of only one unused variable/bad variable doesn't make the whole thing useless.

I haven't said the whole thing is useless and even if it is, I am not in position to point that out.

I saw something that's worth reviewing and I did, I could equally decide to ignore.

furthermore, I'm wondering what you're trying to pass across by " I wrote this code online in some few minutes without even running it".

whichever way, I'll simply advice myself.

2 Likes

Re: I Can Code In 75 Languages!!! by Nobody: 6:21pm On Jul 22, 2016
see code geeks showing themselves. . .
Re: I Can Code In 75 Languages!!! by Craigston: 6:57pm On Jul 22, 2016
tr3y:
Should have pass in the event object instead of this
It's actually better -- a good practice -- to avoid using event triggers and the 'event' object, except there's no other option.
Using event handlers and element queries is better and your program's behavior should be predictable.
Re: I Can Code In 75 Languages!!! by tr3y(m): 8:13pm On Jul 22, 2016
Craigston:

It's actually better -- a good practice -- to avoid using event triggers and the 'event' object, except there's no other option.
Using event handlers and element queries is better and your program's behavior should be predictable.
Well whatever works bro.
I might decide to pass in the whole DOM tree and transverse it till I find the node I'm interested in.
Re: I Can Code In 75 Languages!!! by FincoApps(m): 9:21pm On Jul 22, 2016
Craigston:

It's actually better -- a good practice -- to avoid using event triggers and the 'event' object, except there's no other option.
Using event handlers and element queries is better and your program's behavior should be predictable.

Why ?

And please give a clear reason...
Re: I Can Code In 75 Languages!!! by Nobody: 10:13pm On Jul 22, 2016
FincoApps:


Why ?

And please give a clear reason...
Reason: it is good and recommended practice.
Re: I Can Code In 75 Languages!!! by godofbrowser(m): 11:01pm On Jul 22, 2016
dhtml18:

Reason: it is good and recommended practice.

lol
Re: I Can Code In 75 Languages!!! by Nobody: 11:03pm On Jul 22, 2016
godofbrowser:


lol
I think his ears are not working well, so i have to help him pull it.
Re: I Can Code In 75 Languages!!! by KazukiIto(m): 1:11pm On Jul 23, 2016
Yes! What did I miss?
Re: I Can Code In 75 Languages!!! by tr3y(m): 1:29pm On Jul 23, 2016
KazukiIto:
Yes! What did I miss?
road

1 Like

Re: I Can Code In 75 Languages!!! by Nobody: 1:43pm On Jul 23, 2016
KazukiIto:
Yes! What did I miss?
You missed a whole boatload of trollin'
Re: I Can Code In 75 Languages!!! by KazukiIto(m): 1:46pm On Jul 23, 2016
dhtml18:
You missed a whole boatload of trollin'
Indeed. I've nothing to contribute so, continue...
Re: I Can Code In 75 Languages!!! by KazukiIto(m): 2:16pm On Jul 23, 2016
FincoApps:


Dude, whether you like it or not, you must use the result of other people work.... it does not make you lazy.
You are missing the whole point. I said "there is no soul in hackerism anymore. Everyone is just interested in "copying" and "pasting" calculator programs in the name of having a portfolio. No clever solutions." Vim is an 'improvement' to vi which also is an improvement to ed, which Bill Joy categorically stated that he copied parts of the code from somewhere. Bash (Bourne Again Shell) is a remake of the Bourne shell which gave it some features of csh, ksh ... One thing stands, they improved on the solutions of the old program. That's where I'm striking from. We 'build on' the results of other's discovery, that's how science progress like you rightly mentioned. We are not seeing clever solutions any longer is what I'm ranting about.

Ps: sorry for answering this now, had issues with my acct.

1 Like

Re: I Can Code In 75 Languages!!! by Craigston: 3:18pm On Jul 23, 2016
dhtml18:

Reason: it is good and recommended practice.
That was real scolding for FincoApps. What do you have to say, finco?

FincoApps:


Why ?

And please give a clear reason...
Just think about what happens when you're trying to manage many click events across different versions of a site design and you're using only the 'event' object to determine what event it is and, if it's a click event, which HTML object was clicked. It becomes harder to manage as it grows larger, even with your debugging tools to help. Attaching event triggers to each object of interest makes it easier to manage.
Re: I Can Code In 75 Languages!!! by tr3y(m): 4:57pm On Jul 23, 2016
Craigston:

That was real scolding for FincoApps. What do you have to say, finco?


Just think about what happens when you're trying to manage many click events across different versions of a site design and you're using only the 'event' object to determine what event it is and, if it's a click event, which HTML object was clicked. It becomes harder to manage as it grows larger, even with your debugging tools to help. Attaching event triggers to each object of interest makes it easier to manage.
Who does that?
Listen to all event then use the event Object to determine what event it is? You create event handlers before even thinking of passing the Object
You listen for an event and once it occurs you have your callback to which you pass in the event Object.
that is why we have stopPropagation and preventDefault, how will you make use of them if you don't pass in the event Object to your callback?
Re: I Can Code In 75 Languages!!! by Craigston: 5:47pm On Jul 23, 2016
tr3y:

Who does that?
Listen to all event then use the event Object to determine what event it is? You create event handlers before even thinking of passing the Object
You listen for an event and once it occurs you have your callback to which you pass in the event Object.
that is why we have stopPropagation and preventDefault, how will you make use of them if you don't pass in the event Object to your callback?
Of course you can still use stopPropagation and preventDefault. And it's not different from listening to an event. It only helps you write cleaner, more maintainable code and separates behavior, presentation and structure.
Using html event trigger attributes such as onClick, onBlur, etc mix more JavaScript into your html which should be avoided. Instead of using those, query the elements you're interested in and use addEventListener() to attach event handlers to them. That makes your code more readable. It becomes clearer on first glance what your function is meant to achieve. Your html becomes free of JavaScript too.
I used this technique to write a template for a friend and reading the code was enjoyable. You understand the document structure better since it is almost html alone. Similarly, the JavaScript file was shorter and cleaner.
Re: I Can Code In 75 Languages!!! by tr3y(m): 7:29pm On Jul 23, 2016
Craigston:

Of course you can still use stopPropagation and preventDefault. And it's not different from listening to an event. It only helps you write cleaner, more maintainable code and separates behavior, presentation and structure.
Using html event trigger attributes such as onClick, onBlur, etc mix more JavaScript into your html which should be avoided. Instead of using those, query the elements you're interested in and use addEventListener() to attach event handlers to them. That makes your code more readable. It becomes clearer on first glance what your function is meant to achieve. Your html becomes free of JavaScript too.
I used this technique to write a template for a friend and reading the code was enjoyable. You understand the document structure better since it is almost html alone. Similarly, the JavaScript file was shorter and cleaner.

Okay now I get you.
You are a semantic markup crusader grin, I am too even though I still mix it sometimes (Don't judge).
You still have to worry about cross-browser compatibility especially if you are using vanilla JavaScript.
Re: I Can Code In 75 Languages!!! by godofbrowser(m): 7:44pm On Jul 23, 2016
Craigston:

Of course you can still use stopPropagation and preventDefault. And it's not different from listening to an event. It only helps you write cleaner, more maintainable code and separates behavior, presentation and structure.
Using html event trigger attributes such as onClick, onBlur, etc mix more JavaScript into your html which should be avoided. Instead of using those, query the elements you're interested in and use addEventListener() to attach event handlers to them. That makes your code more readable. It becomes clearer on first glance what your function is meant to achieve. Your html becomes free of JavaScript too.
I used this technique to write a template for a friend and reading the code was enjoyable. You understand the document structure better since it is almost html alone. Similarly, the JavaScript file was shorter and cleaner.

You're making sense. Reminds me of when I learnt javascript at first. I enjoyed adding those event handlers like the onClick, onBlur, etc to my html codes. But after learning jquery, I needed no one to tell me that the addEventListener() makes the project more professional.

it'll be a pleasure reading more tips of this kind. That's part of the reason i joined NairaLand. Thanks.
Re: I Can Code In 75 Languages!!! by Nobody: 8:03pm On Jul 23, 2016
What have you got to say about this?

<body>
<div id="nairaland">
This is awesome!
</div>
</body>
<script>
window.document.getElementById('nairaland').style.backgroundColor='#ceceff';
</script>

(1) (2) (3) (4) (5) (6) (7) (Reply)

Web Design, Web Development And Mobile App Development Tutorial / Learn Android App Development For FREE Here / Is Python A Good Language For Backend Web Development

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 62
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.