Skip to main content

Posts

Showing posts from June, 2018

Software testing techniques (In Arabic)

متى ولماذا يجب علينا اختبار الكود البرمجي؟  عادة ما نواجه -كمبرمجين- مشاكل برمجية مختلفة، نريد الوصول لأفضل حل يمكننا من اجتياز المشكلة. عادة ما يتم تعريف الحل الجيد على أنه الحل الذي يحقق المعادلة التالية: ناتج صحيح مع استخدام موارد أقل في مقابل كفاءة أعلى. لكن التفكير البشري ربما يخطئ حتى في أفضل حالاته، فكيف نتأكد من فعالية حلولنا البرمجية بدقة وكفاءة؟ في السطور التالية سأعرض بعض الآليات والمعايير التي تعلمتها في الأسبوع الأول من الدورة التعليمية ( Algorithmic toolbox ) على منصة Coursera. لكي نقوم بتسهيل المفاهيم التالي ذكرها، سنفترض أننا نقوم بتطوير حل برمجي لمشكلة ما: لنفترض أن لدينا مصفوفة من الأرقام (الموجبة والسالبة) ماهي أكبر قيمة لحاصل ضرب أي رقمين في تلك المصفوفة؟ Input: arr = {1, 4, 3, 6, 7, 0} Output: {6,7} Input: arr = {-1, -3, -4, 2, 0, -5} Output: {-4,-5} تقوم أحد أفكار الحل على مقارنة حاصل ضرب أكبر رقم موجب × ثاني أكبر رقم موجب مع حاصل ضرب أكبر قيمة سالبة × ثاني أكبر قيمة سالبة. ونقوم بعد ذلك باعتماد حاصل الضرب الأكبر بين القيمتين. إذاً، كا...

Code Quality: Enforcing the PEP8 with flake8

  What’s PEP8 ? And why it’s important?   PEP8 (Python Enhancement Proposal 0008) is a document that makes it easy for developers to get familiar with Python coding conventions. It describes and explains the bold lines that you should consider when developing your code in Python. Why it’s important? Imagine that you’re working in a team with other people, you don’t know each other, you don’t know how each one of you think and take decisions. You’ll have to work on these people’s code, you’ll need to understand the basic layout that these people follow when they want to implement their code. So, what it’s going to be like when everyone has his own method? Catastrophic codebase, right? Here the PEP8 comes and saves the day for you and your team! It helps you standardize a set of rules to be followed every time you’re going to change the codebase to implement new features or to review some other existing ones.   WOW, is it unbreakable? Like many other...