Welcome Guest, Not a member yet? Register   Sign In
Naming convention for M V C including file names
#11

[eluser]bengrice[/eluser]
See that was the kind of post i needed earlier wiredesignz. thanks.

Its just the CI user guide does not have the same info in the controller guide. again the controller guide says nothing about file names especially if they are two words ie somecontroller. and logically as controllers seem to be the first thing, thats where i was reading through and had not come to Creating Your Own Libraries or the models guide yet.

they have gone to all the trouble of writing brill documentation and i suppose my 2 pence worth would be add something like the libraries:

Quote:File names must be capitalized. For example: Myclass.php
Class declarations must be capitalized. For example: class Myclass
Class names and file names must match.

to the controllers page, however the system libraries are named different from how the guide says ie Myclass.php but in the system libraries we have Form_validation.php not Formvalidation.php?

thanks anyway

ben
#12

[eluser]Colin Williams[/eluser]
Here's me trying to be helpful:

Controller class: Uppercase first letter of class name. Rest is lowercase. Separate words with underscores.
Controller filename: Lowercase version of Controller class name

Model class: Uppercase first letter of class name. Rest is lowercase. Separate words with underscores.
Model filename: Lowercase version of model class name

View filename: Whatever you like, so long as you correctly provide it when loading the view. Recommended that you stick to all lowercase and use underscores to separate words.

Library class: Uppercase first letter of class name. Rest is lowercase. Separate words with underscores.
Library filename: Should match class name exactly. Uppercase first letter of class name. Rest is lowercase. Separate words with underscores.

(If you are developing your own class, you should prefix your class name with "CI_" to avoid clashing with controller classes. Your filename, however, will not have the "CI_" extension)

Helper filename: All lowercase. Separate words with underscores.
#13

[eluser]Phil Sturgeon[/eluser]
Jondolar & bengrice, you are both ridiculous.


Quote:CI user guide does not have the same info in the controller guide

They are the same thing.

Quote:File names must be capitalized. For example: Myclass.php
Class declarations must be capitalized. For example: class Myclass
Class names and file names must match.

This is not the case! Controllers must have their names lowercase and the PHP class within that file must start upper-case. This is what the user guide says.

Quote:and for the sake of collin (who i feel may be a bit slow)

Colin has been here longer than me. He is somebody who helped me out when I just started off in the world of CodeIgniter and has yet to be wrong in any of our arguments. I follow the guy on twitter and he is always helpful to those who do some work themselves.

Try and think before you start flaming people for jestful comments when you are a ignorant new user to a forum.

Always read the manual, and read it properly. Then search Google. If you still haven't found your answer post here. Don't skip steps 1 and 2 for any reason, ever.
#14

[eluser]bengrice[/eluser]
Cheers Colin, thats perfect.

Phil:

Now you don't seem to be reading, as i opened this with:
Quote:Iv been reading for ages and i cannot find a simple answer for the question
simple being the word.

and im sorry phil, i could say the same, dont assume that new users are ignorant and why for 1 minute should somebody think they have the right to be sarcastic and they are better than others because they have been there done that and posted a million times.

in short they dont, the very nature of a forum is to help others, whether they are as intelligent as god himself or as thick as a s***. whether they can read or not.

im sorry but im just not going to spend hours reading any entire user guide, im a bloke and after all we dont even read an ikea manual. we do what comes natural go at it with a screw driver! and now with the internet you have forums wow! ask a question get a simple answer.

if its in the documentation just point me too it and ill be on my merry way, if not then a simple post, if you have answered the question a million times or think its a waste of time DON'T SAY ANYTHING as some other helpfully sole will try to.

The reason i'm going off on one is because i run my own IT company for 6 years now (and i asked the question because as any coder would know, we have many different coding standards for different languages and projects and as you yourself will know there is no right or wrong answer to this, the key is just consistency. i just wanted be make sure i was consistent with CI) anyway back to my rant :bug: . Im a happy go lucky kind a man, and if i saw either yourself or collin in the street tommorow id probably buy you both a beer and have a giggle at how we were arguing in a forum. however as you know there are some less confident people out there, and ive had countless customer come back to me saying 'i cant use forums as they make me feel silly' or i cant spell etc etc and this is where i say it doesn't really matter. we need to keep forums fun and helpful, even if an answer is already there or has been answered many time before. a police man is not a tomtom satnav and its not in his job description but i wonder in a day, every day haw many times an little old lady asks him for directions. he does'n go off on one saying read a map and then come back to me does he, no, he tells her if he knows the way and doesn't if he don't (or at least thats what they used to do :roll: )

i know documentation is important but iv found in my personal experience time and money are much more important. when i have a client breathing down my neck, im not going to read hours of manuals, i just hit the ground coding. if i need to know something, quick look in any user guides, quick google, ask forum. google is great but too many people now-a-days answer just google for this or google for that, ive bin there done that and spent hours googling for thing and still not found the answer. and what i dont get is 9 times out of 10 i bet the time it takes someone to type back saying google this, or its in such a section of the user guide they probably could have just answered the question and everybody could have been on there merry way!

anyway how long is this reply it should have music from platoon in the background as you read it :lol:

right back to work.

and guys, just to clear up, i say im never arguing or being nasty i just love debate (and sometime they just happen to get heated) :grrr: .... :-)

Cheers all and collin, all joking and debating aside, thanks for your last post, as that answered my question (but couldn't you just have replied with that first and saved all this fuss :cheese: ).

Ben
#15

[eluser]jedd[/eluser]
[quote author="bengrice" date="1249918151"]
i know documentation is important but iv found in my personal experience time and money are much more important. [/quote]

This doesn't make sense (unless you happen to see the world in exactly the same self-centric way that you do).


Quote:when i have a client breathing down my neck, im not going to read hours of manuals, i just hit the ground coding.

This approach will fail you once you try to scale it.

The idea, I believe, is to learn (or 'read the manual' if you prefer) before the client starts breathing down your neck.


Quote:google is great but too many people now-a-days answer just google for this or google for that ..

Probably people who are fed up with continually having to deal with lazy people who are unwilling to invest the (arguably trivial) time and effort to do some research -- and instead believe they should instead just bother forum users in the first instance.

Long-term forum users are selfish (if you look at it from your point of view) and on the whole don't appreciate being asked the same question every few days by some new lazy user who can't read the same manual that they (the aforementioned long-term forum user) originally read and learned from, or the forum archive (ditto), or other tutorial sites on the intergoogle (ditto).


Quote:... 9 times out of 10 i bet the time it takes someone to type back saying google this, or its in such a section of the user guide they probably could have just answered the question and everybody could have been on there merry way!

This assumes that a) your time is more valuable than theirs, and b) the long-term forum user is keen to encourage you in your belief that you are doing The Right Thing by bothering them with pointless and already answered questions. I suggest these beliefs are a significant contributing factor to your problems.
#16

[eluser]John_Betong[/eluser]
 
 
"Arguing on the internet"
 
 
#17

[eluser]Jelmer[/eluser]
I think this topic starter's problem became pretty clear:
Quote:i know documentation is important but iv found in my personal experience time and money are much more important. when i have a client breathing down my neck, im not going to read hours of manuals, i just hit the ground coding.

All I can tell you is that time, money and knowing what you're doing are very connected. When you "just hit the ground coding" you'll make huge mistakes because you don't actually fully understand what you're doing. And not knowing what you're doing leads to:
- Unsafe code
- Instable code
- Non-extendable code
- Unoptimized, inefficient, or to put it bluntly and wrap it up: bad code

Which in turn leads to:
- Unsatisfied customers
- No money
- A lot of time for fixing your mistakes

I wish you all the best, but I would warn anyone against buying anyone's services who works like that. Counting years of experience only has use when you actually understood what you experienced.
#18

[eluser]Johan André[/eluser]
[quote author="Jelmer" date="1249947622"]I think this topic starter's problem became pretty clear:
Quote:i know documentation is important but iv found in my personal experience time and money are much more important. when i have a client breathing down my neck, im not going to read hours of manuals, i just hit the ground coding.

All I can tell you is that time, money and knowing what you're doing are very connected. When you "just hit the ground coding" you'll make huge mistakes because you don't actually fully understand what you're doing. And not knowing what you're doing leads to:
- Unsafe code
- Instable code
- Non-extendable code
- Unoptimized, inefficient, or to put it bluntly and wrap it up: bad code

Which in turn leads to:
- Unsatisfied customers
- No money
- A lot of time for fixing your mistakes

I wish you all the best, but I would warn anyone against buying anyone's services who works like that. Counting years of experience only has use when you actually understood what you experienced.[/quote]

Great post!
You put your finger right on it! Smile

I actually learned something by reading this thread:

There is a "ignore" button and I will use it when encountering people like the dude who wrote "time and money"... I will start ignoring everyone writing dumb posts. Smile
#19

[eluser]Colin Williams[/eluser]
Quote:but couldn’t you just have replied with that first and saved all this fuss

Agreed. But it doesn't mean you should ignore all the other advice you have been offered. Look, when you posted your original question, a lot of us saw a deeper problem: The inability to use resources to your advantage. We know that you can't sustain yourself without that skill, so we are just looking out for you and stressing the importance of being more resourceful (which involves using Google, reading source code, etc). We aren't maliciously leaving you in the dark.
#20

[eluser]bengrice[/eluser]
anyway this thread has morphed to another topic completely now and i feel people are commenting for commenting sake.

and to all those last commenters:

if you can find anything about file names in the controllers section of the user guide (and for that matter google - when specifically talking about CI) your a better man than me. and i made the assumption if its not in the controllers section, its not going to be in the models or library sections either.

anyways thanks all

happy coding

ps same time next week, different topic :lol:

Ben




Theme © iAndrew 2016 - Forum software by © MyBB