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
Tei
Feb 19, 2011

minato posted:

I get stressed doing this because I'm trying not to cause the original author to feel sad (or worse, mad) because I'm very publicly doing something better with their code than they did.

And it also sucks to have to write a justification for the refactor. Making (say) code more testable is an easy sell, but fixing up horrid "cosmetic" issues like bad variable names can really rankle people.


I would be very happy if somebody where refactoring my code. Maybe I would learn a lot from that, more than reading 100 books or reading other people code.

And if the code end doing something awesome, it would be even more happy.

When I am doing my work correctly, nobody tells me anything. The code I have wrote 10 years ago and nobody has talked about ever, is the one with zero bugs that was just perfectly, so people just forget about it.

Adbot
ADBOT LOVES YOU

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

minato posted:

I get stressed doing this because I'm trying not to cause the original author to feel sad (or worse, mad) because I'm very publicly doing something better with their code than they did.

And it also sucks to have to write a justification for the refactor. Making (say) code more testable is an easy sell, but fixing up horrid "cosmetic" issues like bad variable names can really rankle people.

Nothing like that ever even crossed my mind. I think it is more like bad coding practices make the code unclear. Unclear in what it's handling, brittle, like as soon as I touch it the house of cards is going to fall down. People write code that's so bad it can never be touched.

Whereas if I wrote code like that, for the most part I understand what I was trying to do. So that when something breaks I know where to look.

Code isn't people mang, it's just code. Feel free to change it any way you want to.

The Fool
Oct 16, 2003


Nolgthorn posted:


Code isn't people mang, it's just code. Feel free to change it any way you want to.

Code is written by people, and people have egos and feel possessive over things they create. I would not publicly modify someone else's work without at least considering how they would react.

Thermopyle
Jul 1, 2003

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

The Fool posted:

Code is written by people, and people have egos and feel possessive over things they create. I would not publicly modify someone else's work without at least considering how they would react.

Wise words.

Nerds like to feel they're above this, but most of us aren't.

kedo
Nov 27, 2007

As someone whose code is rarely touched by other people, I simultaneously crave and fear the review of a wise third party. I've been making a living coding things for a long time, but my impostor syndrome is strong.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

kedo posted:

As someone whose code is rarely touched by other people, I simultaneously crave and fear the review of a wise third party. I've been making a living coding things for a long time, but my impostor syndrome is strong.

Yeah I'm in the same boat; most of my previous work was one man band infrastructure programming. I'm in a more collaborative environment now and have already survived some PR code reviews though. So far (knock wood) nobody has called anything out, though one was pulled because the solution (given to me by someone else) was deemed insufficient.

my bony fealty
Oct 1, 2008

same except nobody ever looks at my code at all and the only person who will ever is my replacement when I decide to move on. I do my best to keep things readable and sane for them, whoever they may be.

looking at my own predecessor's code has mostly just made me glad we have moved beyond angularjs

Tei
Feb 19, 2011

Somebody need to create a website where people submit his code for randoms to review for free.

Dominoes
Sep 20, 2007

minato posted:

I get stressed doing this because I'm trying not to cause the original author to feel sad (or worse, mad) because I'm very publicly doing something better with their code than they did.

And it also sucks to have to write a justification for the refactor. Making (say) code more testable is an easy sell, but fixing up horrid "cosmetic" issues like bad variable names can really rankle people.
This situation you're alluding to smells of bad attitude and fragile egos.

Munkeymon
Aug 14, 2003

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



Tei posted:

Somebody need to create a website where people submit his code for randoms to review for free.

You mean like https://codereview.stackexchange.com/

Tei
Feb 19, 2011


Oh... cool., I did not knew about that :D

Data Graham
Dec 28, 2009

📈📊🍪😋



I joined a small web dev agency at the beginning of the year which turned out to be focused on a stack I'd never used before and completely rigidly religious about code style.

Long story short, I lasted two months. Short story slightly longer, I now know a million new tricks about eslint and can whip up a Vue/Nuxt site in under a week

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!


I get a lot of info there, but I'm not sure if I'd trust the group mind of stack exchange to build a Kinder Egg toy let alone do code review

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

drat that looks great. And I was sitting here doing it manually, Vue is great.

prom candy
Dec 16, 2005

Only I may dance
Is Nuxt basically Next but with Vue instead of React?

Data Graham
Dec 28, 2009

📈📊🍪😋



Yeah, looks that way. I don't know the React world, but it sure seems to be the same kind of deal.

Speaking of, I now know Vue and some old crufty bits of Angular, but next to nothing about React. I know React has a strong future by the look of things, but am I okay continuing to ignore it?

EL BROMANCE
Jun 10, 2006

COWABUNGA DUDES!
🥷🐢😬



Scaramouche posted:

I get a lot of info there, but I'm not sure if I'd trust the group mind of stack exchange to build a Kinder Egg toy let alone do code review

We've solved the problem of the child possibly swallowing the toy by making the egg larger than the child itself. The new retail cost is $100.

my bony fealty
Oct 1, 2008

Data Graham posted:

Yeah, looks that way. I don't know the React world, but it sure seems to be the same kind of deal.

Speaking of, I now know Vue and some old crufty bits of Angular, but next to nothing about React. I know React has a strong future by the look of things, but am I okay continuing to ignore it?

React has far more demand than Vue or Angular in most markets so if you find yourself in need of new employment it is a good thing to know. But if you can find work without it then theres no practical reason to learn it?

It's a very hot buzzword and hiring managers or recruiters who dont know any better might look at two similar candidates and go with the one who says they know React over the one who doesnt. More techy/smart companies will hopefully understand that if you know Vue well you can probably pick up React fairly quickly and vise versa.

Nuxt was created specifically to be Next for Vue, ya.

Thermopyle
Jul 1, 2003

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

Data Graham posted:

Yeah, looks that way. I don't know the React world, but it sure seems to be the same kind of deal.

Speaking of, I now know Vue and some old crufty bits of Angular, but next to nothing about React. I know React has a strong future by the look of things, but am I okay continuing to ignore it?

I guess that just depends on you.

Personally, I'd try to pick it up so when you lose your job unexpectedly you'll have something else in your toolbelt. Also, knowing more paradigms makes you better at your job.

The basics are not terribly complicated and the official docs are good and fairly succinct.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

my bony fealty posted:

React has far more demand than Vue or Angular in most markets so if you find yourself in need of new employment it is a good thing to know. But if you can find work without it then theres no practical reason to learn it?

It's sort of a dev market out there, there's jobs for vue same as there's jobs for react. There's also a lot more devs that know react and not vue so there's more competition. And if you only went with what was being used most in the industry you'd probably get really good with PHP and jQuery. I wouldn't do it.

Data Graham
Dec 28, 2009

📈📊🍪😋



Heh, thanks, I know it's a weird and open-ended existential kind of question.

The best grift I've hit on so far is to find a startup run by non-technical rich people who fired their lone developer months ago and now need someone, anyone, to come in and fix the bugs that have cropped up over time.

(Downside: "so they can demo/sell it and then fire you too")

my bony fealty
Oct 1, 2008

Nolgthorn posted:

It's sort of a dev market out there, there's jobs for vue same as there's jobs for react. There's also a lot more devs that know react and not vue so there's more competition. And if you only went with what was being used most in the industry you'd probably get really good with PHP and jQuery. I wouldn't do it.

I guess it depends on where you are and what channels you are looking through and what work you want to do. For my time the developer experience with a modern framework is so superior to the jQuery slog that I can't imagine going back. Plus there's not even much need for jQuery these days, JS has caught up and the problems jQuery solved are much less relevant now (much in thanks to JS taking good inspiration from jQuery).

Always bet on PHP though for sure. Can't go wrong practically with that.

I think there is value in exploring things you don't know if only because you might like them and find them interesting? I like spending time learning random JS frameworks tho so ymmv.

Thermopyle
Jul 1, 2003

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

Nolgthorn posted:

And if you only went with what was being used most in the industry you'd probably get really good with PHP and jQuery. I wouldn't do it.

Yes, but React is good and PHP/jQuery is not.

LifeLynx
Feb 27, 2001

Dang so this is like looking over his shoulder in real-time
Grimey Drawer
I want to learn React, and I've been reading that React can be used as a front-end for WordPress. I've been using WordPress exclusively for the past few years, and I think it would be good to replace PHP with React, at least on the front-end where it's possible.

The cleanest tutorial I could find is this: https://www.elegantthemes.com/blog/wordpress/react-js-for-wordpress-users-a-basic-introduction

But I'm stuck at the part that says "React Components and State". Where do I paste that constructor code? Or componentDidMount? If I paste either one into App.js I get errors.

Edit: Trying to learn React has been my meeting with a brick wall for about a year. I've gotten as far as "npx create-react-app app-name" and any tutorial that tries to go beyond that, my brain tries to slam the eject button. What's the best way to learn it, in everyone's expert opinion? I do best with step-by-step instructions and learning by doing.

LifeLynx fucked around with this message at 17:31 on Apr 4, 2019

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

LifeLynx posted:

I want to learn React, and I've been reading that React can be used as a front-end for WordPress. I've been using WordPress exclusively for the past few years, and I think it would be good to replace PHP with React, at least on the front-end where it's possible.

The cleanest tutorial I could find is this: https://www.elegantthemes.com/blog/wordpress/react-js-for-wordpress-users-a-basic-introduction

But I'm stuck at the part that says "React Components and State". Where do I paste that constructor code? Or componentDidMount? If I paste either one into App.js I get errors.

Edit: Trying to learn React has been my meeting with a brick wall for about a year. I've gotten as far as "npx create-react-app app-name" and any tutorial that tries to go beyond that, my brain tries to slam the eject button. What's the best way to learn it, in everyone's expert opinion? I do best with step-by-step instructions and learning by doing.

That tutorial is confusing as all hell.

Looks like that section wants you to make a new component, which would be done like so (I'm using a class because they are using component lifecycle methods, which have to live in a class-based component):

JavaScript code:
class MyComponent extends Component {
  render () {
    return ( <p>WOW!</p> );
  }
}
Every component has to have a render method.

The constructor and component did mount live inside the class along with the render method:

JavaScript code:
class MyComponent extends Component {

  constructor(props) {
    super(props); // this HAS to be here
    
    // put code you want to run when the class is first created in here
    // it's often used to initialize the components internal state
  }

  componentDidMount() {
     // code in here will run once the component has been mounted to the DOM
   }
  
  render () {
    return ( <p>WOW!</p> );
  }
}
If your components don't need do do anything but render (no internal state or anything) you can use functional components:

JavaScript code:
const MyComponent = () => ( <p>WOW!</p> );
If your goal is to learn React, I would not do it that way to start. If integrating with WordPress is your goal, then that's fine, but I'd build a fake blog site first with static data you keep in JSON files or something first so there's one less layer of complexity.

Lumpy fucked around with this message at 18:49 on Apr 4, 2019

my bony fealty
Oct 1, 2008

yeah definitely just focus on learning React before the WordPress integration part. which really just means using the WP REST API as a data source for a decoupled backend. it's pretty nice with Gatsby (which uses React) and throw in the WordPress graphql plugin wp-graphql for some bonus fun.

the official docs have good recs for learning
https://reactjs.org/community/courses.html

I remember the Codeacademy course was quite helpful when I was starting out

LifeLynx
Feb 27, 2001

Dang so this is like looking over his shoulder in real-time
Grimey Drawer

Lumpy posted:

If your goal is to learn React, I would not do it that way to start. If integrating with WordPress is your goal, then that's fine, but I'd build a fake blog site first with static data you keep in JSON files or something first so there's one less layer of complexity.

That's what I just thought of, too. I'll create a mock database in a JSON file with, say, some data about Magic cards or something, and then try to pull that data in.

I was looking into how to do this in Local by Flywheel. If it's not common knowledge, it's a local environment for WordPress sites that handles all the complicated stuff starting a local environment and configuring a database in something like WampServer or whatever. From what I've come to understand though, because of the API it doesn't matter that the React app is even installed on the same server as the WordPress environment, so there's no real "integration" beyond interacting with the API. (Obviously it might help for speed/stability if they're on the same server.)

Once I successfully create a React app (a mock website), what's the best way to host it and make it live? That part's a little confusing because with vanilla JS I don't need a build tool, it just works. Do I need to run some build tool (webpack?) every time?

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

LifeLynx posted:

That's what I just thought of, too. I'll create a mock database in a JSON file with, say, some data about Magic cards or something, and then try to pull that data in.

I was looking into how to do this in Local by Flywheel. If it's not common knowledge, it's a local environment for WordPress sites that handles all the complicated stuff starting a local environment and configuring a database in something like WampServer or whatever. From what I've come to understand though, because of the API it doesn't matter that the React app is even installed on the same server as the WordPress environment, so there's no real "integration" beyond interacting with the API. (Obviously it might help for speed/stability if they're on the same server.)

Once I successfully create a React app (a mock website), what's the best way to host it and make it live? That part's a little confusing because with vanilla JS I don't need a build tool, it just works. Do I need to run some build tool (webpack?) every time?

If you used create-react-app (which you should do!!) you type "npm run build" and then you have a "build" folder which is everything you need is ready to be put up on any hosting you have.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

my bony fealty posted:

(much in thanks to JS taking good inspiration from jQuery).

I think it took much more inspiration from mootools which has always always been the superior tool, it had a better name too. Why jQuery is still used so much in the industry despite vanilla js solving all the problems that it solved is legacy applications. That is what you work on when you stick with out of date technologies.

You will find I assume 0 new applications being written in Ruby on Rails for example.

my bony fealty
Oct 1, 2008

Lumpy posted:

If you used create-react-app (which you should do!!) you type "npm run build" and then you have a "build" folder which is everything you need is ready to be put up on any hosting you have.

+1 for CRA

I guess modern JS has taken inspiration from several places? I dont know enough about the details but if it was more mootools then jQuery thats cool. maybe coffeescript (or just Ruby) too. idk I'm just glad for querySelector and the like.

there's a Ruby shop in my city that seems to be doing well. they also run a bootcamp that spends at least 50% of the time on Ruby and Rails which seems...questionable. the curriculum is all React and Ruby and a dash of SQL and that sounds insane for 12 weeks. I would be pissed if I paid like $13k then found out in would probably have been better off learning full stack JS or .Net or Laravel or something...not Rails.

fond memories of the past age where people were like "lol Node, just stick with Rails it'll be around forever"

Gmaz
Apr 3, 2011

New DLC for Aoe2 is out: Dynasties of India
Rails is still around though? Don't see at all why something like Laravel would be superior choice, it's all similar MVC stuff.

Null of Undefined
Aug 4, 2010

I have used 41 of 300 characters allowed.
Rails is super useful and still pretty ubiquitous,. It's not the hip cool new thing anymore because it's matured.

prom candy
Dec 16, 2005

Only I may dance
Yeah i would definitely consider starting a new project in rails as well, I just wouldn't use Rails to render views. Active Record is a very nice ORM, and Ruby is a nice language. It's far from dead.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I thought Rails died because they did all that work to make it fit with people's single or 1.5 page application aspirations. But it didn't do it very well and added a lot of complexity. So I assumed everyone who wanted classic applications switched because of bloat and people that wanted single page applications switched because there are better options.

prom candy
Dec 16, 2005

Only I may dance
The secret to Rails is to just keep it away from your single page application. You build a REST or GraphQL server application with Rails, and then you build a SPA with a tool that's good for building a SPA. DHH/Basecamp uses Javascript in ways that are completely different from what the rest of the world is doing so it's best to just ignore their ideas on that stuff. It's still very good for back-end though imo, although there are lots of other good options now too.

my bony fealty
Oct 1, 2008

prom candy posted:

The secret to Rails is to just keep it away from your single page application. You build a REST or GraphQL server application with Rails, and then you build a SPA with a tool that's good for building a SPA. DHH/Basecamp uses Javascript in ways that are completely different from what the rest of the world is doing so it's best to just ignore their ideas on that stuff. It's still very good for back-end though imo, although there are lots of other good options now too.

do you know of any reading about how they do stuff that's different? I am very interested, we use Basecamp at work and I have always wondered about its tech. Is this Stimulus framework thing what I should start looking at?

prom candy
Dec 16, 2005

Only I may dance

my bony fealty posted:

do you know of any reading about how they do stuff that's different? I am very interested, we use Basecamp at work and I have always wondered about its tech. Is this Stimulus framework thing what I should start looking at?

No idea, like I said I've basically been ignoring everything they say about javascript since they released turbolinks.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
What is the logical next step after learning Wordpress, CSS, html ? JavaScript?

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Empress Brosephine posted:

What is the logical next step after learning Wordpress, CSS, html ? JavaScript?

What is your overall goal? JavaScript or something server side like Python would probably be a good next step here.

Adbot
ADBOT LOVES YOU

kedo
Nov 27, 2007

JavaScript for sure and/or PHP since you mentioned WordPress.

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