|
Munkeymon posted:haha good point. ajax call on a setTimeout?
|
# ? Nov 11, 2015 19:36 |
|
|
# ? May 16, 2024 18:31 |
|
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.
|
# ? Nov 11, 2015 19:40 |
|
Snak posted:We are using Yii, I'm sorry.
|
# ? Nov 11, 2015 19:42 |
|
Lumpy posted:I'm sorry. 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.
|
# ? Nov 11, 2015 19:46 |
|
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.
|
# ? Nov 11, 2015 19:47 |
|
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. 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 |
# ? Nov 11, 2015 20:24 |
|
kloa posted:For mobile-facing websites, or in general? It isn't, for most cases pushing the same render time to every client is worse than a cached prerender in most cases.
|
# ? Nov 11, 2015 20:24 |
|
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?
|
# ? Nov 11, 2015 23:35 |
|
v1nce posted:Listen to Lumpy; that's the play-by-play of how the app deals with users. 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.
|
# ? Nov 11, 2015 23:59 |
|
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.
|
# ? Nov 12, 2015 00:15 |
|
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.
|
# ? Nov 12, 2015 00:22 |
|
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.
|
# ? Nov 13, 2015 15:13 |
|
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.
|
# ? Nov 13, 2015 15:28 |
|
I like Fastmail, needs suiting, and a decent price.
|
# ? Nov 13, 2015 15:29 |
|
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?
|
# ? Nov 13, 2015 16:35 |
|
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.
|
# ? Nov 13, 2015 17:43 |
|
Does anything look off about this Angular filter implementation?code:
|
# ? Nov 13, 2015 21:02 |
|
Karthe posted:Does anything look off about this Angular filter implementation? 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.
|
# ? Nov 13, 2015 21:10 |
|
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.
|
# ? Nov 13, 2015 21:51 |
|
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.
|
# ? Nov 13, 2015 21:57 |
|
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. IAmKale fucked around with this message at 22:30 on Nov 13, 2015 |
# ? Nov 13, 2015 22:25 |
|
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.
|
# ? Nov 13, 2015 22:29 |
|
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/
|
# ? Nov 14, 2015 00:58 |
|
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 |
# ? Nov 14, 2015 21:41 |
|
The whole point of GWT is using Java instead of JS to do your webdev. http://www.gwtproject.org/overview.html
|
# ? Nov 15, 2015 02:22 |
|
Oh wow, I completely misread that page yesterday.
|
# ? Nov 15, 2015 03:19 |
|
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.
|
# ? Nov 16, 2015 06:16 |
|
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
|
# ? Nov 16, 2015 06:22 |
|
Grump posted:dictionary application [..] Is there a way to run a function in the middle of an SQL query? Grump posted:I have three tables in a MySQL database: words, definitons, and parts of speech. 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:
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. 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:
You can now call this function like so: code:
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.
|
# ? Nov 16, 2015 13:21 |
|
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!
|
# ? Nov 16, 2015 14:25 |
|
React DnD has worked pretty well for me.
|
# ? Nov 16, 2015 14:27 |
|
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: This sounds like a great use case for react-grid-layout: https://github.com/STRML/react-grid-layout
|
# ? Nov 16, 2015 15:55 |
|
v1nce posted:Personally, I'd solve selecting by first letter using a basic text LIKE: Tried this and it worked like a charm. Thank you. v1nce posted:Your code also has some other issues: 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 |
# ? Nov 17, 2015 02:57 |
|
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. 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:
code:
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:
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 |
# ? Nov 17, 2015 04:19 |
|
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. 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. 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...
|
# ? Nov 17, 2015 08:14 |
|
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.
|
# ? Nov 17, 2015 13:25 |
|
v1nce posted:That's fair, we all started somewhere, and you're reminding me a lot of where I started from. This is great advice and I will start doing this for my own code. Thanks!
|
# ? Nov 17, 2015 13:33 |
|
Lumpy posted:The road to UI hell is paved with this statement. 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
|
# ? Nov 17, 2015 17:18 |
|
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.
|
# ? Nov 17, 2015 18:28 |
|
|
# ? May 16, 2024 18:31 |
|
I suspect that Nick Burns is supposed to poke fun at unhelpful IT but I'm finding myself on his side.
|
# ? Nov 17, 2015 18:36 |