What should I upgrade ram or SSD? I have a MacBook pro mid 2012 with 500gb hdd hard drive and 4gb ram. I am a mobile app developer by profession. My hard drive is mainly free with 400+ gb free space. So Should I upgrade the ram or change to SSD?
Depends entirely on your usage.
Since you're thinking about the upgrade, you, supposedly, have performance issues. In /Applications/Utilities/, you can find Activity Monitor. Check the System Memory tab when you experience a performance issue to determine whether the memory is an issue.
If it appears that the memory is nearly full, chances are you need to extend the memory.
Next, switch to Disk Activity tab and remember what you see there.
Download an utility which checks your hard drive speed. I haven't used any tool for Mac OS, so I won't be able to recommend any specific one; you can do a search yourself and chose the one you want. Measure the maximum speed and compare it to what you've seen on the Disk Activity tab.
If it appears that during the performance issues, your disk usage was near its maximum, buy an SSD. If not, your hard disk drive is perfectly fine for your usage.
Obviously, you may find that you don't need any hardware change, or you need to extend the memory and buy an SSD. Act accordingly.
Considering 4GB Ram for app development (and if not heavily resource intensive app development like games, design, cad, etc requiring more than 4GB) on a 2012 MacBook Pro - upgrading the HDD to a 500GB+ SSD will provide the greater performance. I recommend at-least 500GB so you can keep at-least 30%+ free SSD space to maintain optimal performance. There's an instant performance increase waiting for anyone running an OS on an SSD with less than 30% free space - free up over 30% and enjoy.
The performance of SSDs declines after having less than 30% free space due to the way they distribute the read/write operations more effeciently across completely empty blocks rather than fragmented blocks - although you still don't need to defrag SSDs, they automatically re-arrange the data as needed, but with additional data fragment arrangement processes when the free space is too low (even with TRIM enabled to help with deleted/marked-deleted files). This performance drop is even more prominent in near-full HDDs and moving data seeking platter(s) and needle(s) but due to different ways of handling read/write operations for nearly full (more fragmentation prone) drives.
For RAM, having enough to run the OS and needs is first priority - to stay away from using the Virtual Memory backup (additional Virtual RAM on the slower HDD/SSD). After this, topping off your speed from the minimum to the maximum supported by your Motherboard+CPU can provide some additional performance but usually not as significant of an increase as switching from HDD to SSD and increasing RAM capacity on a system that constantly relies on Virtual Memory (doesn't have enough RAM to meet your needs). Faster memory speed is more noticeable in specific applications, but many mistaken it to significantly help increase things like FPS in gaming which is more dependent on the CPU and GPU. Often the cost/performance ratio may not be worth the upgrade if you're only increasing the ram speed a few levels up what's supported, but going from the minimum to maximum supported by a Mobo+CPU may still be worthwhile after the storage speed and capacity are taken care of first.
TL;DR: Replacing an HDD with an SSD is usually the best way to revive & boost an older system like a 2012 MacBook Pro.
Notes: -New MacBook Pros have RAM soldered to the motherboard and can't be upgraded without replacing the entire board with the same compatible board with more RAM (rage table flip indeed).
-Be sure to check the maximum RAM capacity and speed supported by your motherboard (verify CPU support on the RAM speed too). All 2012 MacBook Pros support up to 16GB Ram.