Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Munkeymon posted:

haha good point.

I should have specified I'd need to use it from the client side JS

ajax call on a setTimeout?

Adbot
ADBOT LOVES YOU

Snak
Oct 10, 2005

I myself will carry you to the Gates of Valhalla...
You will ride eternal,
shiny and chrome.
Grimey Drawer
Hello everyone. I am inexperianced at web related things. I know things like C, Java, Python, and a bit of Haskell. I'm working on a group project for school. and this is basically everyone in the groups first time using an MVC framework. We are using Yii, and it seems like it would be pretty easy to grasp if I was at all familiar with how web apps worked.

With the task of understanding this framework divided up among the group, I am tasked with "understanding the controller aspect of Yii". Okay great, so I did some reading and it seems like it's pretty straightforward: The implementation of the procedures performed on the logic that is laid out in the model is implemented in the controller section of the code. Does that sound right? Cause if it doesn't then I'm wrong about the next part.

Part of the reason I am in way over my head here is that other members of the group, who have a lot more experience with html and php than me, are bringing in chunks of code they wrote for other projects or whatever and just dumping them in the Views part of the framework. Like for example, the php code that handles login/permissions. It seems to me that this should be implemented in the controller and called by the view, not implemented completely in the view. But I'm so out of my depth here I don't really have any business telling someone that we need to change the structure of their implementation because of what I think I understand about the Yii framework.

If any of you have advice or can recommend resources that could help me better understand how things should be implemented, that would be amazing. The simpler the better, because like I said, web development is totally new territory for me.

Thanks.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Snak posted:

We are using Yii,

Thanks.

I'm sorry. :smith:

Snak
Oct 10, 2005

I myself will carry you to the Gates of Valhalla...
You will ride eternal,
shiny and chrome.
Grimey Drawer

Lumpy posted:

I'm sorry. :smith:

Just what I want to hear. We actually switched from Zend 2 after none of us could make the turtorial work. We started looking at Yii and CodeIgnitor and in the time it took me to read through a tutorial for CodeIgnitor, our front-end guy got a Yii framework up and running, so we decided it was a sign and went with it. None of use have ever used an MVC framework before, and to say that the group doesn't have a clear picture of what the goals of our project are would be the understatement of the semester.

I never would have guessed that this would be the class that would make me consider dropping out of school again.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Blinkz0rz posted:

ajax call on a setTimeout?

Not everyone has access-control-allow-origin: *

Basically this is the service Suspicious Dish was talking about the other day in that other thread I'm too lazy to look up.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Snak posted:

Just what I want to hear. We actually switched from Zend 2 after none of us could make the turtorial work. We started looking at Yii and CodeIgnitor and in the time it took me to read through a tutorial for CodeIgnitor, our front-end guy got a Yii framework up and running, so we decided it was a sign and went with it. None of use have ever used an MVC framework before, and to say that the group doesn't have a clear picture of what the goals of our project are would be the understatement of the semester.

I never would have guessed that this would be the class that would make me consider dropping out of school again.

So, to be helpful you were absolutely right in your previous post that login should be handled in a controller. In fact, anything that "does stuff" should be in a controller. Views get some data and render it. That's it. Obviously they can do "UI Stuff" like hide / show elements on the page, pop dialogs and so on, but in your case, when it comes time for the applciation to do something, you make a request and a controller handles it.

I don't know the particulars of Yii, but most of the web frameworks I've used work along the lines of this:

A user goes to your site, and click the "login" link / button / whatever. Their browser sends a request to your web server. A router of some sort looks and says "Oh, they want /login, I should send this to the Auth (or whatever you call it) Controller!".

The Auth controller sees that it's a GET request, and decides to render the LoginForm view.

The person gets back a page with username and password inputs. The page might have client side validation / error handling here w/ javascript.

User submits the form, and your router sees another request to /login, and sends it to the Auth Controller again. The controller sees it's a POST so now it does it's own validation (because you never, ever, ever, ever trust the client) and if that passes, interacts with the Model to see if the login succeeded. If not, it will choose to render the LoginForm view again, with error information along with it so you can tell the user they are dumb. If the login was successful, you might choose to render a different View ("Dashboard" or whatever) or pass the request to a different Controller to let it figure out what to do.

As the user goes through the app, that's the pattern. Router checks the request, passes it to a Controller, controller gets (or updates) data from the Model if needed, and renders a View that likely has Model data along for the ride. Ex: A ToDo app's Controller would request a list of the user's ToDos from the Model, and pass that to the View, and the View would loop over it and make a nice list of checkboxes. When a user clicks a checkbox to mark an item as "done" the Controller updated the Model, and passes the new list to the View again where it's re-rendered.

Hopefully that wasn't too simplistic, and I'm sure someone will correct where I've given you bad advise, but that's the gist of it.

Lumpy fucked around with this message at 20:26 on Nov 11, 2015

Funking Giblet
Jun 28, 2004

Jiglightful!

kloa posted:

For mobile-facing websites, or in general?

I figured it'd be beneficial (ie: less costly) to have everything render on their computer, and not the server.

It isn't, for most cases pushing the same render time to every client is worse than a cached prerender in most cases.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

Snak posted:

The implementation of the procedures performed on the logic that is laid out in the model is implemented in the controller section of the code. Does that sound right? Cause if it doesn't then I'm wrong about the next part.

Listen to Lumpy; that's the play-by-play of how the app deals with users.

The business logic is in the Controller, the view logic (mostly) is in the View. The data structure is your Model. Controllers manipulate models and then shove things to the View for users to see.
Model View Controller (MVC) is the ground-floor of "separation of concerns". Your Model is re-used in all sorts of places, so it's a separate class. Your Controller and View do different things, so the point at which your Controller finishes with application logic and passes data to your view; that's a clear line in the sand between the two systems. Try not to muddy these separations.

Snak posted:

Part of the reason I am in way over my head here is that other members of the group, who have a lot more experience with html and php than me, are bringing in chunks of code they wrote for other projects or whatever and just dumping them in the Views part of the framework. Like for example, the php code that handles login/permissions. It seems to me that this should be implemented in the controller and called by the view, not implemented completely in the view.

Don't fight against your framework by trying to roll your own everything. Often you can ask yourself "surely someone has done this before?" and then hit up google and look for a friendly article or SO question.
For example; Installing Yii Users and rights in 5 steps. If you find yourself coming across code and you go "this isn't how you do it in Yii" then you should explain and make the other person learn how to do it in Yii.

Also, didn't I tell you in the other thread to use Laravel? :colbert:

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

v1nce posted:

Listen to Lumpy; that's the play-by-play of how the app deals with users.

The business logic is in the Controller, the view logic (mostly) is in the View. The data structure is your Model. Controllers manipulate models and then shove things to the View for users to see.
Model View Controller (MVC) is the ground-floor of "separation of concerns". Your Model is re-used in all sorts of places, so it's a separate class. Your Controller and View do different things, so the point at which your Controller finishes with application logic and passes data to your view; that's a clear line in the sand between the two systems. Try not to muddy these separations.


Don't fight against your framework by trying to roll your own everything. Often you can ask yourself "surely someone has done this before?" and then hit up google and look for a friendly article or SO question.
For example; Installing Yii Users and rights in 5 steps. If you find yourself coming across code and you go "this isn't how you do it in Yii" then you should explain and make the other person learn how to do it in Yii.

Also, didn't I tell you in the other thread to use Laravel? :colbert:

I'm not sure what Yii's paradigm is but I tend to lean more towards fat models and skinny controllers. Really your models should be multi-component with a DAO and a service layer or repository.

The idea is that the controller is the transmission method for data to flow from the view to the data later and back. That way you can test your controllers in your integration tests and not worry about unit testing the whole request/response lifecycle along with your logic.

On the other side, you maintain a data object that maps to your database (ORM class or whatever you're using) and a service object or repository that does your business logic. Testing can be done on individual pieces and when testing your service/repository you can mock objects coming from the database as well as calls coming from the controller.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

Blinkz0rz posted:

Services, DAO, ORM

I'm a Symfony2 dev, so that's my bread and butter. Seeing the trouble Snak has had so far though, I didn't want to give him the shits by suggesting he introduce the concept of Services to Yii, which doesn't use them as part of its basic concepts.
It's more like CakePHP with ActiveRecord and a bunch of statics, but like I said; don't fight the framework.

If he was developing something for a company and not just academia I would absolutely push him down those stairs.

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS
Oh sure, I wasn't implying he should go whole hog. I was just suggesting that if he wants to do it right, he should put his business logic in the models instead of in the controllers as was suggested.

fuf
Sep 12, 2004

haha
I'm looking for an alternative to Zoho to provide email to clients.

I've been really impressed with Mandrill - is there anything as slick as that for normal mailboxes?

One cool thing about Zoho is they only charge you for actual mailboxes, not forwarding and aliases. I have a lot of generic "contact@domain.com" email addresses that just forward somewhere and don't need a full mailbox, and I don't want to have to pay for these.

Google Apps is my backup but just wondering if there's a (preferably cheaper per user) alternative.

Casimir Radon
Aug 2, 2008


Has there been some recent development with Firefox that would cause problems with interactive SVG? We made some maps for a class using Inkscape's xml editor and they work great except under Firefox. Tested with Chrome and Opera, no problems.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
I like Fastmail, needs suiting, and a decent price.

Withnail
Feb 11, 2004
We are doing an intranet web app where we need to send domain passwords over the network, everything is on https (http is shut down). Is there a best practice for client/server encryption in this scenario, meaning should we also be doing our own encryption/decrpytion between client and server, or just letting ssl do its thing?

revmoo
May 25, 2006

#basta
Just let SSL do its thing. There's a lot more at stake with an ssl exploit than some domain passwods. If security in your org was higher priority you'd probably be using 2-factor auth.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
Does anything look off about this Angular filter implementation?

code:
var searchFilter = function(value, index) {
    console.log(value);
    return value.shifts[DateUtils.getDBDate(vm.shift.date_requested, true)] != null;
};

var filtered = $filter('filter')(employees, searchFilter);
console.log('filtered:', filtered);
I'm trying to filter out any object in employees that has a shift on the given date. However, the console.log() inside searchFilter never appears in the console so I'm wondering if the function is even being called. I know I'm doing something wrong because the "filtered" objects that appear below the $filter call aren't filtered at all, but without being able to see the value that gets passed into the filter I'm unable to figure out what I'm screwing up.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Karthe posted:

Does anything look off about this Angular filter implementation?

code:
var searchFilter = function(value, index) {
    console.log(value);
    return value.shifts[DateUtils.getDBDate(vm.shift.date_requested, true)] != null;
};

var filtered = $filter('filter')(employees, searchFilter);
console.log('filtered:', filtered);
I'm trying to filter out any object in employees that has a shift on the given date. However, the console.log() inside searchFilter never appears in the console so I'm wondering if the function is even being called. I know I'm doing something wrong because the "filtered" objects that appear below the $filter call aren't filtered at all, but without being able to see the value that gets passed into the filter I'm unable to figure out what I'm screwing up.

This is sort of an aside, but there is little point in using the $filter service if you are not going to be calling your filters from your templates via |. If you are going to do the work in code, you might as well just do it with a for loop or something like Underscore or Lodash. Also, keep in mind that filters called via | are always executed at least twice, as it happens during the $digest loop, so if it is in any way expensive, moving it out of there is also a good idea to keep your $digests tight.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

Skandranon posted:

This is sort of an aside, but there is little point in using the $filter service if you are not going to be calling your filters from your templates via |. If you are going to do the work in code, you might as well just do it with a for loop or something like Underscore or Lodash. Also, keep in mind that filters called via | are always executed at least twice, as it happens during the $digest loop, so if it is in any way expensive, moving it out of there is also a good idea to keep your $digests tight.
Oh, I'd just started moving some filtering out of the views and into the controller after reading about that and thinking "there's no point in things filtering twice". I also viewed it as a preventative measure - what if the datasets I'm filtering balloon above the couple of records that I'm working with now? It seemed pragmatic, but the things I read left it unclear at what point filtering done in the view should be moved to the controller.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Karthe posted:

Oh, I'd just started moving some filtering out of the views and into the controller after reading about that and thinking "there's no point in things filtering twice". I also viewed it as a preventative measure - what if the datasets I'm filtering balloon above the couple of records that I'm working with now? It seemed pragmatic, but the things I read left it unclear at what point filtering done in the view should be moved to the controller.

Most of the web apps I work on require a significant focus on the $digest cycle, so I prefer to keep it doing as little as possible. If you are just doing a simple app, and there are already built in filters for what you want, go ahead. I don't like $filter because it's one of those Angular features that seems like magic, but scales poorly.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

Skandranon posted:

Most of the web apps I work on require a significant focus on the $digest cycle, so I prefer to keep it doing as little as possible. If you are just doing a simple app, and there are already built in filters for what you want, go ahead. I don't like $filter because it's one of those Angular features that seems like magic, but scales poorly.
Oh, your point is to skip $filter completely! I see. Then it should be just as good to angular.copy() a controller variable, for() through it to remove unneeded values, and then re-set that new object back to the controller variable?

IAmKale fucked around with this message at 22:30 on Nov 13, 2015

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Karthe posted:

Oh, your point is to skip $filter completel! I see. Then it should be just as good to angular.copy() a controller variable, for() through it to remove unneeded values, and then re-set that new object back to the controller variable?

There probably isn't a reason to even use angular.copy(), just create a new variable as the result set, and push the values you want to it. Keep 2 sets of information, the full set (probably stored in a service somewhere and only changes when getting from server or whatever) and the filtered set in the controller. The controller is responsible for assigning the filtered set, but doesn't need to create new values, just needs to add the references to the filtered set. When you assign the new filtered set, this will trigger any $watches you have keeping an eye on it, but you won't have created an entirely new set of records for it.

huhu
Feb 24, 2006
I've got a basic situation where I want content to move to a new line depending on screen size. The thing is at some screen widths, the description for an image will wrap around and cause empty spaces where there should be an image. Made a JSFiddle to explain the situation. What should I be changing?

http://jsfiddle.net/fccmwazL/

22 Eargesplitten
Oct 10, 2010



I'm hopefully going in for a second round interview, and the first round the interviewer suggested I look into GWT, because they use that for their websites. Is there any good guide on it?

E: I have no experience with webdev, and they didn't mention anything about webdev in the job description, so I'm a little worried. Going to have to study some JS, I guess.

22 Eargesplitten fucked around with this message at 22:25 on Nov 14, 2015

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
The whole point of GWT is using Java instead of JS to do your webdev. http://www.gwtproject.org/overview.html

22 Eargesplitten
Oct 10, 2010



Oh wow, I completely misread that page yesterday.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
I'm in the process of making a dictionary application for my senior project this semester, and I've hit a wall and haven't been able to solve it for a week an a half. My inital question is this: Is there a way to run a function in the middle of an SQL query? I'll list what I've done so far, but I'm assuming there's an easier way.

I have three tables in a MySQL database: words, definitons, and parts of speech. In the words table, I have a column for the first letter of the word, so I can properly sort them with values from 1-26 for the letters.

I need a way to look at the first letter of the word as it is submitted, and store it with the correct letters "lol" should have "12" and "Asdf" should have "1."



For this, I first created an array in a functions.php file which looks like this



Secondly, I created a function in a database.php file to get the first letter of the word:



And then used array_search to compare the first letter to the array. Add _Word is run when the submit button in pressed on a form I've made. The SQL queries run smooth because I have functions in a database.php file that makes it easier to write. Just can't figure out how to store first_letter. $key should return the correct number, if I'm doing this right:



I really just need help on where to use the function I've created and what the proper syntax is.

Impotence
Nov 8, 2010
Lipstick Apathy
flip key / value over in $alphabet and look for $alphabet[get_firstletter($str)] so you have $alphabet = ['a' => 1];

array_search somewhat overkill when you can do a single constant time lookup since you already know the array index

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

Grump posted:

dictionary application [..] Is there a way to run a function in the middle of an SQL query?
Not like, native PHP. For the most part when these kinds of questions come up the answer is "do a better query" or "how can i get a limited subset of data i can then quickly manipulate".

Grump posted:

I have three tables in a MySQL database: words, definitons, and parts of speech.
In the words table, I have a column for the first letter of the word, so I can properly sort them with values from 1-26 for the letters.
I know this isn't part of the scope of your original question, but I honestly don't get why you would make a sort column that's just the same order as the letters in the alphabet.
I mean perhaps in an enormo-huge database you might see a small return using an ID WHERE early on and then order by the word text, but initially that's a massive over-optimization.

Personally, I'd solve selecting by first letter using a basic text LIKE:
code:
SELECT * FROM words WHERE word LIKE "A%" ORDER BY word
That eradicates the need to store that index value, right?
You'll need to use UTF8_GENERAL_CI for the case-insensitive LIKE to work. See this SO article for more info.

Your code also has some other issues:
- Your get_firstletter can only handle lowercase first letters, because that's all you've got in the array, so you'll need strtolower() your letter before you array_search for it.
- Your array is 1-26 a-z, and an ascii table is 92-122 a-z. You could make the same index using chr() and a for loop. Or your get_firstletter() could become get_firstletter_index() and just use ord() and subtracting 91.
- You're returning before your echo, so you won't see that message displayed, ever.

Grump posted:

And then used array_search to compare the first letter to the array. Add _Word is run when the submit button in pressed on a form I've made.
Just can't figure out how to store first_letter. $key should return the correct number, if I'm doing this right:

Citing what I said above, I still don't think its necessary to get the first letter in order for your application to work. But I shouldn't be telling you how to run your life. What you've got will work (with lowercase words).
Yes, there's a small argument for using array_flip and then key lookup being faster, but eh. Don't optimize too early at the sacrifice of readability.

What I would point out, is your code isn't very readable, and most of that is due to the fact you're using extract().
Let me explain it in the opposite direction; I was looking at the code and wondering where $def came from. It wasn't passed in as an argument, and it wasn't until i saw extract() that i realised it was being magically vomitted out of $info. That's way too much reading for me, and one day you might come back to this function and discover it's way too much reading for you, too.

extract() is a risky and annoying function, it relies on your array structure not changing, and any errors related to its use usually manifest as "undefined variable" which is an annoying mis-step when debugging. Try to avoid it. Like globals.

Your code would be far more readable if it was modified like so:
code:
function add_word($word, $def, $pos)
{
    // Get DB
    $db = $GLOBALS['db'];
    
    // Insert the text definition
    $submitted = $db->query("INSERT INTO definition VALUES ('', '$def', '$pos')");
    
    // Determine first letter index, and add to DB
    $key = $db->get_firstletter($word);
    $timestamp = $db->get_mysql_timestamp();
    $db->query("INSERT INTO word (id, firstletter, word, did, timestamp) VALUES ('', '$key', '$word', '$db->lastID', '$timestamp')");

    // Clean my pajamas ("clean" isn't very descriptive?)
    $whatIsthisFor = $db->clean($submitted);

    // Success message
    echo sprintf('<div><h3>%s submitted!</h3></div>', $word);
    return $whatIsthisFor;
}
Why is this better? Well, we know all the variables that are required for the function to work ($word, $def, $pos) and there'll be no surprises if our original incoming data is missing its array members.
You can now call this function like so:
code:
$someStupidValue = add_word($wordData['word'], $wordData['def'], $wordData['pos']);
Now if you gently caress up and forget to set 'pos' or arse about with the array structure and forget to change a usage, the "undefined variable" error will happen where you called add_word, rather than inside it.

Also, if you're planning to stick with PHP outside of your course, then when you're done smashing your brain on this system give these articles a read:
Using PDO instead of MySQL for database and Don't trust user submitted data.

Also comment loving everything. I know a lot of smart coders say "i can read the code i don't need comments" however comments provide context about what it should be doing not what it is doing. Any programmer can tell you what it is doing, but only the author can tell me what it should be doing.

Mostly Sober
Nov 27, 2014
[img][/img]
Hi guys, I've just joined a small research project as a developer working on a learning analytics dashboard that looks similar to this:



They want the ability to drag and drop/reorder the individual cards at will using react. Would any front-end pros be able to point me in the right direction with regards to developing something like this, or any plugins that I can use to implement this functionality?

I've primarily been on the back-end till now and aren't too sure where to start, thanks!

Depressing Box
Jun 27, 2010

Half-price sideshow.
React DnD has worked pretty well for me.

Chenghiz
Feb 14, 2007

WHITE WHALE
HOLY GRAIL

Mostly Sober posted:

Hi guys, I've just joined a small research project as a developer working on a learning analytics dashboard that looks similar to this:



They want the ability to drag and drop/reorder the individual cards at will using react. Would any front-end pros be able to point me in the right direction with regards to developing something like this, or any plugins that I can use to implement this functionality?

I've primarily been on the back-end till now and aren't too sure where to start, thanks!

This sounds like a great use case for react-grid-layout: https://github.com/STRML/react-grid-layout

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

v1nce posted:

Personally, I'd solve selecting by first letter using a basic text LIKE:
code:
SELECT * FROM words WHERE word LIKE "A%" ORDER BY word
That eradicates the need to store that index value, right?
You'll need to use UTF8_GENERAL_CI for the case-insensitive LIKE to work. See this SO article for more info.

Tried this and it worked like a charm. Thank you.

v1nce posted:

Your code also has some other issues:
- Your get_firstletter can only handle lowercase first letters, because that's all you've got in the array, so you'll need strtolower() your letter before you array_search for it.
- Your array is 1-26 a-z, and an ascii table is 92-122 a-z. You could make the same index using chr() and a for loop. Or your get_firstletter() could become get_firstletter_index() and just use ord() and subtracting 91.
- You're returning before your echo, so you won't see that message displayed, ever.
- What I would point out, is your code isn't very readable, and most of that is due to the fact you're using extract().
- Also comment loving everything. I know a lot of smart coders say "i can read the code i don't need comments" however comments provide context about what it should be doing not what it is doing. Any programmer can tell you what it is doing, but only the author can tell me what it should be doing.

Haha. The thing about this code is that I don't understand half of it. A lot of functions that I'm using are recycled from a professor's example project that he said I would benefit from using and modifying.

I'm really bad at PHP. Like, this is my senior project and I'm realizing I don't know this poo poo nearly as much as I'd like to. It's seriously giving me anxiety. Most of this project is me trying to teach myself what this code means and changing variables to fit my needs.

As for commenting, yeah. I should get in the habit of doing that.

teen phone cutie fucked around with this message at 03:47 on Nov 17, 2015

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

Grump posted:

I'm really bad at PHP. Like, this is my senior project and I'm realizing I don't know this poo poo nearly as much as I'd like to. It's seriously giving me anxiety. Most of this project is me trying to teach myself what this code means and changing variables to fit my needs.
That's fair, we all started somewhere, and you're reminding me a lot of where I started from.

If you're looking for help more relevant to PHP-land, you can go over to the PHP thread and we can try to push you in the right direction. We're not particularly quick to reply, but we can help explain what's doing what and why.

I'm guessing one of your big problems is you don't know what tools are available in the toolbox yet, so getting from A to B requires quite a bit of discovery, and coupled with straight-up learning PHP syntax and quirks it's going to be rough going.
If you want to fix some of that anxiety and paralysis, you can just straight up write pseudo code as TODO statements, and then fill-in-the-blanks from easiest to hardest. I use this quite a lot when I can't immediately think my way through a problem.

For instance, say I asked you to build me a function which exchanged the first letter of a word for a fancy image of that letter, like old-timey novels.
All you know from this is you'll be inputting a word and outputting HTML. So that gives you your function signature, like so:
code:
/**
 * Exchange the first letter of the given word with an image of that letter
 * @param string $word
 * @return string  Html output with fancy capitalisation
 */
function fancyCapitalise($word)
{
    // TODO: figure this out
    return $word;
}
With that signature I can now plug the function into a bunch of places, but obviously it aint going to do poo poo. Let's go ahead and handle that first TODO and expand on the action:
code:
// TODO: Strip the first letter off the word
$letter = 'A';

// TODO: Create the HTML for the image for that letter
$html = '<img>';

return $html.$word;
So this is an improvement, kinda. We've outlined all the actions this function needs to take, and we're returning something reminiscent of the desired output, but we're still not getting bogged down in code details.

This also gives us the opportunity to think about any special cases we've missed. Perhaps you have a sudden realisation that you don't want it to do this if the word starts with a non-ascii alphabet character, so you might also put a bail-out statement near the start:
code:
// TODO: Strip the first letter off the word
$letter = 'A';

// TODO: Determine if letter is non-ASCII alpha.
if (false) {
	// Return word without modification when incompatible.
	return $word;
}

// ...
Notice we only put if (false) { rather than any actual logic. We don't currently know how to check if the character is a-z or not, but rather than get hung up on the fine details we'll just TODO it and have that if clause be false, so it never gets executed.

The point is, you can design the application logic without knowing what you're doing. Dumping end-to-end pseudo code that have kinda-sorta working interfaces means you at least know what you want the system to do, and you've got it all commented out in front of you. How you make it actually connect the dots and execute those tasks something you can waste your time researching, ask your professor, or ask us about.

v1nce fucked around with this message at 04:44 on Nov 17, 2015

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

Thermopyle posted:

As an aside: Icons are very difficult to do right. As a rule of thumb, prefer labels. Labels are harder for designers but better for users.

That's not to say there aren't common icons that are easy to use like the pencil icon, magnifying glass, etc.

LP0 ON FIRE posted:

The combination of icons plus text labels are the strongest. Icons are great, but you have to learn their meaning first, but when you do, you can more quickly recognize it than text alone. The combination of icons plus labels gives everyone the advantage by giving direct meaning of the icon.

Facebook for iPhone is the perfect example:


*Note I didn't blur out the person's name because it's an example on some design site.

Thanks guys, I've taken all the advice offered and I have just an icon for the "View" links, its a right facing arrow that looks really obvious to me. When I'm back at work I'll send updated screenshots. For most others I've used the text label + icon combination as suggested.

As an aside, I wanted to gloat a little about how much I'm loving my work right now. We have been through some tense poo poo lately with changes of ownership redundancies etc. Now we finally are settled with a manager who kicks rear end and we're getting awesome poo poo done. And just when I thought I was just about over this career...

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

The Wizard of Poz posted:

... that looks really obvious to me.

The road to UI hell is paved with this statement.

I'm not saying your icon isn't obvious, but a rather shockingly large number of times I've thought something was "brain dead obvious" to users, it wasn't. The good news is, you can test this stuff really, really easily and find out. A half hour of user testing is worth it's weight in gold.

chami
Mar 28, 2011

Keep it classy, boys~
Fun Shoe

v1nce posted:

That's fair, we all started somewhere, and you're reminding me a lot of where I started from.

If you're looking for help more relevant to PHP-land, you can go over to the PHP thread and we can try to push you in the right direction. We're not particularly quick to reply, but we can help explain what's doing what and why.

I'm guessing one of your big problems is you don't know what tools are available in the toolbox yet, so getting from A to B requires quite a bit of discovery, and coupled with straight-up learning PHP syntax and quirks it's going to be rough going.
If you want to fix some of that anxiety and paralysis, you can just straight up write pseudo code as TODO statements, and then fill-in-the-blanks from easiest to hardest. I use this quite a lot when I can't immediately think my way through a problem.

For instance, say I asked you to build me a function which exchanged the first letter of a word for a fancy image of that letter, like old-timey novels.
All you know from this is you'll be inputting a word and outputting HTML. So that gives you your function signature, like so:
code:

/**
 * Exchange the first letter of the given word with an image of that letter
 * @param string $word
 * @return string  Html output with fancy capitalisation
 */
function fancyCapitalise($word)
{
    // TODO: figure this out
    return $word;
}
With that signature I can now plug the function into a bunch of places, but obviously it aint going to do poo poo. Let's go ahead and handle that first TODO and expand on the action:
code:

// TODO: Strip the first letter off the word
$letter = 'A';

// TODO: Create the HTML for the image for that letter
$html = '<img>';

return $html.$word;
So this is an improvement, kinda. We've outlined all the actions this function needs to take, and we're returning something reminiscent of the desired output, but we're still not getting bogged down in code details.

This also gives us the opportunity to think about any special cases we've missed. Perhaps you have a sudden realisation that you don't want it to do this if the word starts with a non-ascii alphabet character, so you might also put a bail-out statement near the start:
code:

// TODO: Strip the first letter off the word
$letter = 'A';

// TODO: Determine if letter is non-ASCII alpha.
if (false) {
	// Return word without modification when incompatible.
	return $word;
}

// ...
Notice we only put if (false) { rather than any actual logic. We don't currently know how to check if the character is a-z or not, but rather than get hung up on the fine details we'll just TODO it and have that if clause be false, so it never gets executed.

The point is, you can design the application logic without knowing what you're doing. Dumping end-to-end pseudo code that have kinda-sorta working interfaces means you at least know what you want the system to do, and you've got it all commented out in front of you. How you make it actually connect the dots and execute those tasks something you can waste your time researching, ask your professor, or ask us about.

This is great advice and I will start doing this for my own code. Thanks!

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Lumpy posted:

The road to UI hell is paved with this statement.

I'm not saying your icon isn't obvious, but a rather shockingly large number of times I've thought something was "brain dead obvious" to users, it wasn't. The good news is, you can test this stuff really, really easily and find out. A half hour of user testing is worth it's weight in gold.

Man, isn't this the truth.

It takes a special type of person to be able to watch a user using your product and not want to go Nick Burns on them.

https://www.youtube.com/watch?v=tfKL6RM8hsY

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Yeah, the last thing I had a hand in designing had a menu so I just used the usual hamburger icon to represent it's button and save some visual space on the small-screen layout. Seems perfect, right? It's pretty much ubiquitous, compact and doesn't require internationalization. Wins all around. A week after release, someone in sales demanded I put a text label on it "because users are clueless" and I couldn't really disagree with that reasoning.

Adbot
ADBOT LOVES YOU

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes
I suspect that Nick Burns is supposed to poke fun at unhelpful IT but I'm finding myself on his side.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply